Create new folder in shared folder(windows file sharing) in windows 7 using webclient
I want to create/delete a folder in a Windows 7 network sharing folder. I can create/delete folder just fine u开发者_JAVA技巧sing windows explorer. I can download file from the folder just fine using c# webclient. But since there is no method to create/delete folder in webclient, i cant create/delete folder using webclient. is there a way to create/delete folder in a windows 7 shared folder using webclient? or i should use ftpwebrequest?
thanks.
If it's a network shared folder then you should be able to use the standard libraries for creating files/folders without any networking code. Take a look at this article for instruction on how to create folders. Let's say the folder is on a networked machine called COMPUTER, then you'd do something like
public class CreateFileOrFolder
{
static void Main()
{
string activeDir = @"\\COMPUTER";
string newPath = System.IO.Path.Combine(activeDir, "myNewFolder");
System.IO.Directory.CreateDirectory(newPath);
}
}
精彩评论