尝试使用 StreamWriter 写入 .vcf 文件
Attempt to write .vcf file using StreamWriter
我想使用 streamWriter 写一个 vcard 文件 class 但我遇到了这个异常,这是什么意思以及如何解决?问候...
例外情况是:
FileStream 不会打开磁盘分区和磁带机等 Win32 设备。避免在路径中使用“\.\”。
private void button1_Click(object sender, EventArgs e)
{
string contactTemplate = "BEGIN:VCARD\nVERSION:3.0\nN:1;mtn;;Mr.;\nFN:mtn 1\nPHOTO;VALUE=URI;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif \nTEL;TYPE=WORK,VOICE:734641900\nEND:VCARD";
StreamWriter txt = new StreamWriter("E:\Omar Project\con.vcf");
txt.Write(contactTemplate);
txt.Close();
}
您可以在 MSDN
的 Naming Files, Paths and Namespaces 中阅读此警告
Do not use the following reserved names for the name of a file: CON,
PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9,
LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid
these names followed immediately by an extension; for example, NUL.txt
is not recommended. For more information, see Namespaces.
使用不同的文件名 CON 是保留的设备名称
StreamWriter txt = new StreamWriter("E:\Omar Project\CONDATA.vcf");
我想使用 streamWriter 写一个 vcard 文件 class 但我遇到了这个异常,这是什么意思以及如何解决?问候...
例外情况是:
FileStream 不会打开磁盘分区和磁带机等 Win32 设备。避免在路径中使用“\.\”。
private void button1_Click(object sender, EventArgs e)
{
string contactTemplate = "BEGIN:VCARD\nVERSION:3.0\nN:1;mtn;;Mr.;\nFN:mtn 1\nPHOTO;VALUE=URI;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif \nTEL;TYPE=WORK,VOICE:734641900\nEND:VCARD";
StreamWriter txt = new StreamWriter("E:\Omar Project\con.vcf");
txt.Write(contactTemplate);
txt.Close();
}
您可以在 MSDN
的 Naming Files, Paths and Namespaces 中阅读此警告Do not use the following reserved names for the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. For more information, see Namespaces.
使用不同的文件名 CON 是保留的设备名称
StreamWriter txt = new StreamWriter("E:\Omar Project\CONDATA.vcf");