Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI

I have a sub folders in my app_data as following

APP_DATA/North/Delhi/Metro/North_delhi_metro.xml file so

when i am loading i am getting a error as following

C#
Could not find a part of the path 'C:\Users


So i am using the following way for accessing the file

C#
 string file= "~/App_Data/NORTH/DELHI/METRO/NORTH_DELHI_METRO.xml"

<pre lang="C#">xmlDoc.Load(Server.MapPath(file));</pre>


so Thanks for your help guys

Error I am getting

C#
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, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
   at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
   at System.Threading.CompressedStack.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
   at System.Xml.XmlTextReaderImpl.OpenUrl()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.Load(String filename)


What I have tried:

C#
 string file= "~/App_Data/NORTH/DELHI/METRO/NORTH_DELHI_METRO.xml"

<pre lang="C#">xmlDoc.Load(Server.MapPath(file));</pre>
Posted
Updated 14-Mar-16 21:39pm
v2
Comments
[no name] 11-Mar-16 1:50am    
Just cross check where is your original file path and get the file path in Server.Mappath. Both should be same.
manoj1412012 11-Mar-16 2:26am    
Ya Manas I have cross checked path and i am getting the correct Path and Thanks For the help Manas
Sinisa Hajnal 11-Mar-16 2:51am    
Are you checking on the computer where your app is running (server) or in your own? Conversely, if you're doing work on localhost, did you check your own computer or server? Does the application have access rights to the folder?
F-ES Sitecore 11-Mar-16 6:56am    
The code is ok, so check your site is running under the interactive user to ensure it has access to the "users" folder.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900