Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在服务器上创建具有指定路径的目录_C# - Fatal编程技术网

C# 在服务器上创建具有指定路径的目录

C# 在服务器上创建具有指定路径的目录,c#,C#,我的域路径如下:https:\\lurman.gimy.y\files\\car\\ 我有一个例外,如下所示: 不支持给定路径的格式 我正在尝试使用以下代码在服务器上创建目录: public void MakeDirectory(string path) { path = path.Replace("/", @"\"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path);

我的域路径如下:
https:\\lurman.gimy.y\files\\car\\

我有一个例外,如下所示:

不支持给定路径的格式

我正在尝试使用以下代码在服务器上创建目录:

public void MakeDirectory(string path)
{
    path = path.Replace("/", @"\");

    if (!Directory.Exists(path))
    {
        Directory.CreateDirectory(path);
    }
}
但我有上述例外。有人能澄清我做错了什么吗?

试试下面的方法

string sPath = Server.MapPath(@"~\ApplicationDir\YourFoldername");    

 if (!Directory.Exists(sPath))
 {
     Directory.CreateDirectory(sPath);
 }

无法通过
http
https
协议创建目录


您可以在
文件系统
共享外部资源
中执行此操作,您可以通过
\\lurman.gimy.y\files\\car\\\

这样的路径到达该路径的开头是否应该有
https:
?如果您在NAS上处理文件和文件夹,您应该使用SMB而不是HTTPS(1)请提供一个
路径
值的示例,(2)如果路径值为
http://
,最好使用
System.IO.path.directoryseportorchar
,而不是硬编码的
@“\”
,您应该删除
http
字符串。只需确保路径值
“files”
“files/car”
,但我想在服务器上创建目录。如何指定路径?我的虚拟路径为:`https:\\lurman.gimy.y\files\\car\`您只能(安全地)从本地网络执行此操作。话虽如此,您可以使用以下结构利用协议:
\\ServerName\Share\FolderOrFile
。让我们来看看你的网络路径。在本例中,服务器名为“lurman.gimy.y”,共享名为“files”,共享文件夹中有一个“cars”文件夹。它看起来像这样:
\\lurman.gimy.y\files\car
。如果这不可行,你也可以试试。这与最初的问题有什么关系?为什么您认为这可以解决问题?但是我想在服务器上创建目录。如何指定路径?我的虚拟路径为:`https:\\lurman.gimy.y\files\\car\`与您的计算机共享服务器并使用虚拟路径。Https不一定是一个虚拟路径。我怎么能做到呢?我不知道,它不是程序员知道的。通常我有一个系统管理员来做这些事情。HTTPS是一个协议,它不是路径的一部分。要设置共享,请查看和。如果这还不包括你的操作系统,谷歌搜索“在[你的操作系统]上设置smb共享”,你应该能够找到一些东西。