Although the IO class in .net in C# is very powerful, it is not practical on the servers of many virtual service providers because of its powerful functions. Because IO.Directory and IO.DirectoryInfo will traverse the disk and directory of the hard disk where the website is located when operating the application folder. Generally, virtual service providers will not enable read permissions for Network service users of this disk, so when operating the folder When using these two classes under IO, the following error will appear: Part of the path "E:" was not found.
Explanation: An unhandled exception occurred during execution of the current web request. Please check the stack trace for more details about the error and where in the code that caused it.
Exception details: System.IO.DirectoryNotFoundException: Part of path 'E:' not found.
Source Error:
An unhandled exception was generated during the execution of the current web request. You can use the exception stack trace information below to determine information about the cause and location of the exception.
Stack trace:
[DirectoryNotFoundException: Part of path 'E:' not found. ]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +287
System.IO.Directory.InternalCreateDirectory(String fullPath, String path) +489
System.IO.Directory.CreateDirectory(String path) +195
-----------------------
Version information: Microsoft .NET Framework version: 1.1.4322.2300; ASP.NET version: 1.1.4322.2300
Path E was not found: /, E drive is the disk path on the server, which may vary depending on the server. Faced with this problem and the service provider refuses to grant you more permissions, how should you solve it?
Haha, maybe it’s because my basic knowledge is relatively poor, so I searched for answers online, but I couldn’t find the answer. By chance, I discovered that asp can create folders using fso. So I thought of using asp.net to call the fso component in window. Haha, it actually worked. I write this article for those friends and brothers who are struggling with this problem and cannot solve it.
Project->Reference Browse COM Component Microsoft Scripting Runtime
Scripting.FileSystemObject fso=new Scripting.FileSystemObjectClass();
fso.CreateFolder(Path)
is enough, but the premise of this solution is that the virtual service provider has turned on FSO
as for the IO operation file Why the two sandwiched classes traverse the root directory of the disk is still under study, but the problem has finally been solved. I hope people who know this can give you an answer.
http://www.cnblogs.com/ccc110/archive/2006/12/22/600480.html