question

deskcheck1-0579 avatar image
0 Votes"
deskcheck1-0579 asked Bruce-SqlWork answered

.NET CORE 3.1 Console Application: How to reference data path from another drive

Hi,

I have a .NET Core 3.1 Console Application that has a working data folder located in a different drive from where my VS Project/Solution is located. It's a huge data folder (about half a terabyte size).

It seems like my .netcore3.1 application is looking for the data inside the .netcore3.1 folder.

How do I reference the other drive where my data is located? Right now it's throwing a "DirectoryNotFoundException".

Must I place the working folder in the same drive/directory where my application is located? I have my app in my computer's C Drive. But since the working data folder is huge, I need to place it inside a different drive with bigger capacity than my C Drive. My C Drive is reserve for applications only.

Appreciate any advice.

dotnet-runtimedotnet-cli
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @deskcheck1-0579 ,
Did you get the exception in the code? Or did an exception occur when starting the project?
Here's a reference you may need: Visual Studio retrieving an incorrect path to a project from somewhere


0 Votes 0 ·

Exception occurs during runtime. I think the issue is WHERE to place data files in .netcore projects. I can't find anything in the Internet addressing this issue. Because of this issue, I can't create a standalone executable. Seems weird such an important aspect of where data should be stored is not addressed in .net core literature.

0 Votes 0 ·

By the way, there is NO error thrown when I run the app WITHOUT debugging. The error occurs when I create a SETUP project for my console application. Sorry. I should have made that point.

0 Votes 0 ·

Hi @deskcheck1-0579 ,
Thanks for your feedback.
Could you provide more details about how you create the SETUP project and which line of the code thrown the "DirectoryNotFoundException"?

place the working folder in the same drive/directory where my application is located

Will the exception still occur after the folder is placed in the directory where the application is located?
We are waiting for your update.

0 Votes 0 ·

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

core 3.1 does not work any different than any other windows app. file paths are relative to the working folder you run the app from. the file path syntax is the same for all windows apps.

how are you specifying the path in code?

is a user running the app, or a system service?

does the user running the app have permission to the folder and files?




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.