how to read a file from a different project?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
how to read a file from a different project?
I have a solution:
Solution1
-MyProject
-MyProject.Artifacts
----Message.XML
-MyProject.Tests
I am attempting to read the contents of Message.XML
from MyProject.Tests
.
How do I read the contents of Message.XML
from MyProject.Tests
?
Unfortunately, right now I'm doing something like this, but it's not very pretty:
var currentDir = Directory.GetCurrentDirectory();
var parentDir = Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName;
var parentParentDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName).FullName;
var parentParentParentDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName).FullName).FullName;
c# .net visual-studio visual-studio-2017
add a comment |
how to read a file from a different project?
I have a solution:
Solution1
-MyProject
-MyProject.Artifacts
----Message.XML
-MyProject.Tests
I am attempting to read the contents of Message.XML
from MyProject.Tests
.
How do I read the contents of Message.XML
from MyProject.Tests
?
Unfortunately, right now I'm doing something like this, but it's not very pretty:
var currentDir = Directory.GetCurrentDirectory();
var parentDir = Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName;
var parentParentDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName).FullName;
var parentParentParentDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName).FullName).FullName;
c# .net visual-studio visual-studio-2017
What kind of application is it? Web, Console or WPF ...? I think you can define the XML output folder yourself. Thus, you can refer to this: stackoverflow.com/questions/6041332/…
– wannadream
Nov 16 '18 at 20:12
its an azure function
– l--''''''---------''''''''''''
Nov 16 '18 at 20:46
add a comment |
how to read a file from a different project?
I have a solution:
Solution1
-MyProject
-MyProject.Artifacts
----Message.XML
-MyProject.Tests
I am attempting to read the contents of Message.XML
from MyProject.Tests
.
How do I read the contents of Message.XML
from MyProject.Tests
?
Unfortunately, right now I'm doing something like this, but it's not very pretty:
var currentDir = Directory.GetCurrentDirectory();
var parentDir = Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName;
var parentParentDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName).FullName;
var parentParentParentDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName).FullName).FullName;
c# .net visual-studio visual-studio-2017
how to read a file from a different project?
I have a solution:
Solution1
-MyProject
-MyProject.Artifacts
----Message.XML
-MyProject.Tests
I am attempting to read the contents of Message.XML
from MyProject.Tests
.
How do I read the contents of Message.XML
from MyProject.Tests
?
Unfortunately, right now I'm doing something like this, but it's not very pretty:
var currentDir = Directory.GetCurrentDirectory();
var parentDir = Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName;
var parentParentDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName).FullName;
var parentParentParentDir = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(currentDir).FullName).FullName).FullName).FullName;
c# .net visual-studio visual-studio-2017
c# .net visual-studio visual-studio-2017
asked Nov 16 '18 at 19:47
l--''''''---------''''''''''''l--''''''---------''''''''''''
11.4k238543885
11.4k238543885
What kind of application is it? Web, Console or WPF ...? I think you can define the XML output folder yourself. Thus, you can refer to this: stackoverflow.com/questions/6041332/…
– wannadream
Nov 16 '18 at 20:12
its an azure function
– l--''''''---------''''''''''''
Nov 16 '18 at 20:46
add a comment |
What kind of application is it? Web, Console or WPF ...? I think you can define the XML output folder yourself. Thus, you can refer to this: stackoverflow.com/questions/6041332/…
– wannadream
Nov 16 '18 at 20:12
its an azure function
– l--''''''---------''''''''''''
Nov 16 '18 at 20:46
What kind of application is it? Web, Console or WPF ...? I think you can define the XML output folder yourself. Thus, you can refer to this: stackoverflow.com/questions/6041332/…
– wannadream
Nov 16 '18 at 20:12
What kind of application is it? Web, Console or WPF ...? I think you can define the XML output folder yourself. Thus, you can refer to this: stackoverflow.com/questions/6041332/…
– wannadream
Nov 16 '18 at 20:12
its an azure function
– l--''''''---------''''''''''''
Nov 16 '18 at 20:46
its an azure function
– l--''''''---------''''''''''''
Nov 16 '18 at 20:46
add a comment |
2 Answers
2
active
oldest
votes
You can store a path to the file in app settings of app.config / web.config using that read the file contents.
That way if you need to deploy your software in a different way you have the flexibility
then i will need to maintain two sets of configuration files, one in my regular project and one in my tests project
– l--''''''---------''''''''''''
Nov 16 '18 at 19:53
Or us a config transform so when you run test you get set of values and run production you get a different set
– thepolishboy
Nov 16 '18 at 19:54
add a comment |
If your path is fixed, you can write the path like "c:projectssolution ... Message.xml"
If you want a relative path, the simplest way is this:
var DI = new DirectoryInfo("..\..\..\..\Your Folder\Message.XML");
This path is started from CurrentDirectory and goes four folders up and the one folder down and finds the file.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53344434%2fhow-to-read-a-file-from-a-different-project%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can store a path to the file in app settings of app.config / web.config using that read the file contents.
That way if you need to deploy your software in a different way you have the flexibility
then i will need to maintain two sets of configuration files, one in my regular project and one in my tests project
– l--''''''---------''''''''''''
Nov 16 '18 at 19:53
Or us a config transform so when you run test you get set of values and run production you get a different set
– thepolishboy
Nov 16 '18 at 19:54
add a comment |
You can store a path to the file in app settings of app.config / web.config using that read the file contents.
That way if you need to deploy your software in a different way you have the flexibility
then i will need to maintain two sets of configuration files, one in my regular project and one in my tests project
– l--''''''---------''''''''''''
Nov 16 '18 at 19:53
Or us a config transform so when you run test you get set of values and run production you get a different set
– thepolishboy
Nov 16 '18 at 19:54
add a comment |
You can store a path to the file in app settings of app.config / web.config using that read the file contents.
That way if you need to deploy your software in a different way you have the flexibility
You can store a path to the file in app settings of app.config / web.config using that read the file contents.
That way if you need to deploy your software in a different way you have the flexibility
answered Nov 16 '18 at 19:53
thepolishboythepolishboy
246
246
then i will need to maintain two sets of configuration files, one in my regular project and one in my tests project
– l--''''''---------''''''''''''
Nov 16 '18 at 19:53
Or us a config transform so when you run test you get set of values and run production you get a different set
– thepolishboy
Nov 16 '18 at 19:54
add a comment |
then i will need to maintain two sets of configuration files, one in my regular project and one in my tests project
– l--''''''---------''''''''''''
Nov 16 '18 at 19:53
Or us a config transform so when you run test you get set of values and run production you get a different set
– thepolishboy
Nov 16 '18 at 19:54
then i will need to maintain two sets of configuration files, one in my regular project and one in my tests project
– l--''''''---------''''''''''''
Nov 16 '18 at 19:53
then i will need to maintain two sets of configuration files, one in my regular project and one in my tests project
– l--''''''---------''''''''''''
Nov 16 '18 at 19:53
Or us a config transform so when you run test you get set of values and run production you get a different set
– thepolishboy
Nov 16 '18 at 19:54
Or us a config transform so when you run test you get set of values and run production you get a different set
– thepolishboy
Nov 16 '18 at 19:54
add a comment |
If your path is fixed, you can write the path like "c:projectssolution ... Message.xml"
If you want a relative path, the simplest way is this:
var DI = new DirectoryInfo("..\..\..\..\Your Folder\Message.XML");
This path is started from CurrentDirectory and goes four folders up and the one folder down and finds the file.
add a comment |
If your path is fixed, you can write the path like "c:projectssolution ... Message.xml"
If you want a relative path, the simplest way is this:
var DI = new DirectoryInfo("..\..\..\..\Your Folder\Message.XML");
This path is started from CurrentDirectory and goes four folders up and the one folder down and finds the file.
add a comment |
If your path is fixed, you can write the path like "c:projectssolution ... Message.xml"
If you want a relative path, the simplest way is this:
var DI = new DirectoryInfo("..\..\..\..\Your Folder\Message.XML");
This path is started from CurrentDirectory and goes four folders up and the one folder down and finds the file.
If your path is fixed, you can write the path like "c:projectssolution ... Message.xml"
If you want a relative path, the simplest way is this:
var DI = new DirectoryInfo("..\..\..\..\Your Folder\Message.XML");
This path is started from CurrentDirectory and goes four folders up and the one folder down and finds the file.
answered Nov 16 '18 at 20:10
MSLMSL
5361918
5361918
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53344434%2fhow-to-read-a-file-from-a-different-project%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What kind of application is it? Web, Console or WPF ...? I think you can define the XML output folder yourself. Thus, you can refer to this: stackoverflow.com/questions/6041332/…
– wannadream
Nov 16 '18 at 20:12
its an azure function
– l--''''''---------''''''''''''
Nov 16 '18 at 20:46