Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tilde (~) in Absolute Path

Status
Not open for further replies.

JonTurlington

Programmer
Nov 12, 2008
4
US
I am receiving a System.IO.FileNotFoundException when attempting to access a path like "C:\Path\~somePath\Path\file.ext" it reports the error:

System.IO.FileNotFoundException: Could not find file 'C:\Path\~s'. File name: 'C:\Path\~s' at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)

 
tilde is for relative paths. you can map a relative path to an absoulte path using Server.MapPath example
Code:
Server.MapPath("~/directory/file.ext");

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Yes sir, but there is a tilde in the AbsolutePath and it is not liking it. Is there any way to make it work?
 
The path is being directly referred to by C:\Path\~somePath\Path\file.ext

There is a tilde in the path, it's not in any way meant to refer to it was relative.
 
not sure about that. is there anyway you can remove the non-alphanumeric characters from the path?

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top