简体   繁体   English

如何使用.net WindowsForm在服务器上创建文件夹和文件

[英]How to create Folder and files on Server using .net windowsForm

I am working on windows form, i have one task to create directory and files on My client server using windows Form. 我正在Windows窗体上工作,我有一项任务要使用Windows窗体在我的客户端服务器上创建目录和文件。 So how can i create Directory and Files on Client 那么我如何在客户端上创建目录和文件

Server using my windows/Desktop Application. 使用我的Windows /桌面应用程序的服务器。

Thanks 谢谢

I have no idea.. Means how can i authenticate my desktop to My Live Server 我不知道..意味着我该如何验证我的Live Server的桌面身份

I was Just trying that code but its not working 我只是在尝试该代码,但无法正常工作

string path= "\\ipaddress\\Templates\\";
System.IO.Directory.CreateDirectory(@path);

If i try this one 如果我尝试这个

string path = "\\123.100.000.000\KapilSearch\";

I am having following error 我有以下错误

[Error  1   Unrecognized escape sequence]
[Error  2   Newline in constant]

Your path is escaped incorrectly. 您的路径未正确转义。 You have two options. 您有两个选择。

string path= @"\\ServerName\ShareName\targetnewfolder";
System.IO.Directory.CreateDirectory(path);

or this: 或这个:

string path = "\\\\ServerName\\ShareName\\targetnewfolder";
System.IO.Directory.CreateDirectory(path);

Note the @ in front of the open string - and that the slashes are equal to the number you would use in windows explorer - no escapes required when using the @ modifier. 注意打开的字符串前面的@-斜线等于您在Windows资源管理器中使用的数字-使用@修饰符时不需要转义。 Note also, no @ sign in the CreateDirectory argument. 还要注意,CreateDirectory参数中没有@符号。

如果你问如何创建一个目录,那么这很简单,只要: Directory.CreateDirectory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM