How to locate the path of other drive's folder in server?
For ex: The a开发者_如何转开发pplication is there in 'C:\SomeFolder\', now I want to export a file to the drive 'D:\AnotherFolder\' on the server. How can I achieve this?
First of all you need to have permissions to access the folder. The user that needs to be able to access the folder is the same user as is running IIS. Usualy it is a built in account IIS_*
that is running the instance.
As long as this user has access to the folder, you can just use File Read / Write as you normally do.
Read this article about C# File Handling.
Example - Search for files on another drive
var files = Directory.GetFiles("D:\\", "*.txt");
This will give you an array of files with the extension .txt
found on D:\
.
Also read this: How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)
If you mean to get a list of all drives known on a system you can use Environment.GetLogicalDrives.
精彩评论