输出文本文件名中双引号的问题 [英] problem with double quotes in output text file name

查看:966
本文介绍了输出文本文件名中双引号的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WebClient的DownloadFile方法从URL读取XML文件,并将其写到本地驱动器中,以导入到另一个系统中.

我需要将选择的日期附加到文件名中.我的问题是我不知道如何处理文件名中的引号和反斜杠.

文件名最终应类似于:@"c:\ fileout_08112010.xml"

整个语句当前看起来像:
wc.DownloadFile(inURL,@"c:\ fileout_08112010.xml");

任何想法或提示,尤其是直接的知识,将不胜感激!

谢谢!

I am using the DownloadFile method of WebClient to read in an XML file from a URL and write it out to a local drive for import into another system.

I need to append the date selected to the filename. My problem is that I can not figure out how to deal with the quotes and the backslash in the file name.

The file name should end up looking like: @"c:\fileout_08112010.xml"

The entire statement currently looks like:
wc.DownloadFile(inURL, @"c:\fileout_08112010.xml");

Any ideas or hints and especially direct knowledge would be very much appreciated!

Thanks!

推荐答案

似乎您正在使用C#.使用该语言时,必须在反斜杠和引号之前加上反斜杠,以使其转义.因此,您的文件名看起来像@\"c:\\fileout_08112010.xml\".否则,C#会将引号视为定界符,并将反斜杠+ f视为单个转义字符.
It looks like you are using C#. In that language, backslashes and quotes must be escaped by preceeding them with a backslash. So, your file name would look like @\"c:\\fileout_08112010.xml\". Otherwise, C# will treat the quote as a delimiter and the backslash + f as a single escaped character.


这篇关于输出文本文件名中双引号的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆