简体   繁体   中英

Relative Paths Visual Studios

For school, my group has been tasked with continuing development of a Visual Studio application. I don't have too much experience with this, as I've only used Visual Basic a few times about 6 years ago.

One of the bugs that I have to fix deals with saving an image to a folder. When I run the "debug" mode of the code, it saves the image fine. However if I publish the website using Visual Studios, the page errors because it cannot find the folder. I cannot hard code the directory, I have to use a relative path.

This is my current code:

String path = Server.MapPath("~") + "sig/img.png"

This code also works on the debug mode, but not on the publish:

String path = Server.MapPath("/") + "sig/img.png"

When I try using either System.IO.Path.GetFullPath(path) or System.IO.Path.Combine(basePath, file), it returns a link that starts in ProgramFiles/MicrosoftVisualStudios/

I'm not sure it makes a difference, but all dev work is being done in C:\\Users\\UserName\\program, and it's being published to C:\\inetpub\\wwwdocs\\program

Any help is appreciated. (One thing that might help is being able to trace the variable "path", but I don't know how to do that once I publish.)

Credit goes to spender and WLin. Was a permission error that I overlooked.

Thanks for the help everyone!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM