如何为控制台应用程序提供自动转义的输入字符串?
我的意思是在我的代码中,我可以做到
public static void main(string[] args)
{
string myURL;
myFolder = @"C:\temp\january\"; //just for testing
myFolder = args[0]; // I want to do this eventually
}
如何为 myFolder 提供值而无需通过命令行手动转义?
如果可能的话,我想避免像这样调用这个应用程序:
C:\test> myapplication.exe "C:\\temp\\january\\"
编辑:如果可能的话,我宁愿像这样调用应用程序
C:\test> myapplication.exe @"C:\temp\january\"
谢谢你。
编辑:
这实际上是针对调用 Sharepoint Web 服务的控制台应用程序。我试过了
string SourceFileFullPath, SourceFileName, DestinationFolder, DestinationFullPath;
//This part didn't work. Got Microsoft.SharePoint.SoapServer.SoapServerException
//SourceFileFullPath = args[0]; // C:\temp\xyz.pdf
//SourceFileName = args[1]; // xyz.pdf
//DestinationFolder = args[2]; // "http://myserver/ClientX/Performance" Reports
//This worked.
SourceFileFullPath = @"C:\temp\TestDoc2.txt";
SourceFileName = @"TestDoc2.txt";
DestinationFolder = @"http://myserver/ClientX/Performance Reports";
DestinationFullPath = string.Format("{0}/{1}", DestinationFolder, SourceFileName);