win7 32位环境变量 [英] win7 32bit environment variables
本文介绍了win7 32位环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码适用于winXP,Win7 64位,但不适用于Win7 32位.我收到一条错误消息,说找不到文件"C:\ Users \ John \ Documents \ notes.txt".
使用(StreamReader sr = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)+"\\ notes.txt"))
The following code works on winXP, Win7 64bit, but not on win7 32bit. I get an error saying can''t find file ''C:\Users\John\Documents\notes.txt''.
using (StreamReader sr = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\notes.txt"))
推荐答案
尝试打印Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\notes.txt")
作为字符串,以了解其不同之处.
Try printing the value of Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\notes.txt")
as a string, to see why it is different.
请尝试以下操作:
Try this instead:
string pfile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "notes.txt");
using (StreamReader sr = new StreamReader(pfile);
这篇关于win7 32位环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文