I have a C # assembly that loads external files. This assembly is used by the asp.net website. The following is the code that loads the data files
string DataDirectory = Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly () location), "Data".); FilePath = Path.Combine (DataDirectory, _fileName); This component works well in the Windows App, but when I try to use it in the asp.net website it fails because the site could not locate the files, And this gives me the following error:
C: \ Microsoft.NET \ v4.0.30319 \ Windows \ Framework Temp ASP.NET Files \ cmictranslatorsite \ 20a8eddd \ 864b2575 \ Assembly \ DL3 \ 5bd4a35e \ 8c6f79b6_98eccb01 \ data \ file.txt
You can find the relative physical paths in ASP.NET Have You need to use. \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP: Applications
Path.GetDirectoryName (. Assembly.GetExecutingAssembly () location) Returning Net Files \ cmictranslatorsite \ 20a8eddd \ 864b2575 \ Assembly \ DL3 \ 5bd4a35e \ 8c6f79b6_98eccb01 \ , which is the right place where your application files are copied and executed by. If you want a directory relative to IIS in your virtual directory, you use Server.MapPath to get the path. If your data path may not be a place to store this path, then the .config In either case, check application pool identity or your authenticated users can use the path you are reading or writing to do proper.
Comments
Post a Comment