Ted pottel
Ted pottel

Reputation: 6983

.NET VB trying to load in a file from the in the project directory, says cannot find file

I cannot reaf files from the current directory. If I give it a absolute path name, works fine. I get a file not found error, saying C:\programfiles\Commenfiles\Micrsoftshare\devserver\10.0\stormdoor.html. A interested fact is that my project is not stored in the folder it says it’s current, the project is stored in C:\useres\tedpoottel\mydouments\Visual studio 2010\WEbSites\master2

Upvotes: 0

Views: 257

Answers (2)

Kevin Up
Kevin Up

Reputation: 801

Perhaps you can approach the problem a different way and just make the file an embedded resource.

Upvotes: 0

paulsm4
paulsm4

Reputation: 121649

1st question - is this "vb.net" (a Windows program), or "asp.net" (running in a web server)? It makes a difference :)

2nd note: your startup path (e.g. Application.StartupPath()) might not be where you expect.

Suggestions:

1) Call Directory.GetCurrentDirectory to see where the program "thinks" it's running.

http://msdn.microsoft.com/en-us/library/system.io.directory.getcurrentdirectory%28v=vs.71%29.aspx

2) Modify your code and/or your project resources as needed

Upvotes: 1

Related Questions