C# では、パラメーターとして webPath または fileSystemPath とファイル名を受け取るメソッドを作成する必要があります。このメソッドは、asp.net と Windows フォーム プロジェクトから呼び出されることを考慮してください。これは私が想定しているケースであり、これまでに書いたコードは次のとおりです。
string webPath1 = "//someaddress";
string webPath2 = "//someaddress/";
string fsPath1 = @"\\somefolder";
string fsPath2 = @"\\somefolder\";
string filename = "somefilename.txt";
string WebPathFileName1 = System.IO.Path.Combine(webPath1, filename);
string WebPathFileName2 = System.IO.Path.Combine(webPath2, filename);
string s1 = Path.GetFullPath(WebPathFileName1);
string FsPathFileName1 = System.IO.Path.Combine(fsPath1, filename);
string FsPathFileName2 = System.IO.Path.Combine(fsPath2, filename);
string s2 = Path.GetFullPath(FsPathFileName1);
コードをテストすると、WebPathFileName1 が " //someaddress\\somefilename.txt
" を返すことがわかりますが、" " で応答する必要があります//someaddress//somefilename.txt
。
The input path could end or not end with\
パスを結合するために他にどのような方法を使用できますか? ありがとう。
私が知っているように、プロジェクトリーダーから詳細が届くかもしれません。アイデアは、私が言ったように、このメソッドは 2 種類のプロジェクトから呼び出されるということです。そのため、Web パスまたはファイル システム パスを構成する必要があります。