string strEnd; //标签文本结束内容 int offSet;//结束标签文本的偏移量 FileInfo fi = new FileInfo(file); fi.Attributes =FileAttributes.Normal; if(fi.Extension == ".sln")//如果是解决方案文件 { strStart = "GlobalSection(SourceCodeControl)"; strEnd = "EndGlobalSection"; offSet = 19;//包含\r\n和空格 } else//如果是项目文件 { strStart = "SccProjectName"; strEnd = ">"; offSet = 0; } try { int start;//Vss标签文本开始索引 int end;//Vss标签文本结束索引 string content;//文件内容 using(FileStream fs = new FileStream(file,FileMode.Open,FileAccess.ReadWrite,FileShare.ReadWrite)) { StreamReader sr = new StreamReader(fs); content = sr.ReadToEnd(); |