WINDOWS7下VC++ 6.0 无法打开文件(打开文件时软件崩溃)的解决办法。

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/a_xiong_90/article/details/50382178

由于兼容性的问题,在WIN7下使用VC++6.0的时候,再点击打开文件按钮之后,会出现程序崩溃,如下图:


解决这个问题也比较简单,按照下面的几步操作即可:

1.下载文件FileTool.dll。(百度下自己下载即可)

2.强下载下来的文件放到VC的安装目录\Common\MSDev98下,如图:


3.点击“工具-定制”按钮,选择附加项和宏文件,最后点击浏览。

4.选择文件(注意文件类型为全部文件)


5.勾选圈出的部分,点击关闭按钮。

6.蓝色的这个''o"就是打开文件的按钮。

接下来就可以正常打开了。


展开阅读全文

StreamReader( 打开文件无法关闭

10-20

[code=csharp]rnprotected void Button3_Click(object sender, EventArgs e) rn rn // 先判断文件是否存在 rn string filepath = ""; rn string filename = ""; rn string riqi = ""; rn riqi = DateTime.Now.ToString("MM") + DateTime.Now.Date.ToString("dd"); rn filename = "a11003_" + riqi + ".txt"; //完整的文件名; rn string savePath = "upfiles\\" + filename;//Server.MapPath 获得虚拟服务器相对路径 rn if (!File.Exists(Server.MapPath(savePath))) rn rn Common.ShowMessage.Show(Page, "Error", "文件不存在,请确认是否上传!"); rn return; rn rn else rn rn //这里开始读文件 rn ReadFile(savePath); rn rn rn rnrnrnrn public void ReadFile(string Path) rn rn rn string strLine = ""; rn int i = 0; rn string account = ""; rn string account_name = ""; rn double jfye = 0; rn double dfye = 0; rn double jfjs = 0; rn double dfjs = 0; rn rn string cis = ""; rn string bbh = ""; rn string bz = ""; rn string kmh = ""; rn string c_date = ""; //日期 rnrn // try rn // rn StreamReader sr = new StreamReader(Server.MapPath(Path), Encoding.GetEncoding("GB2312")); rn strLine = sr.ReadLine().ToString().Trim(); rn string[] result; rn while (strLine != null) rn rn rn rn result = Regex.Split(strLine.ToString().Trim(), @"\s+"); rn //分离出每个字段 保证金要特殊处理 rn account = result[0].Trim(); rn account_name = result[1].Trim(); rn if (result[0] == "ACCNO") //标题直接踢了 rn rn strLine = sr.ReadLine().ToString().Trim(); rn continue; rn rnrn if (account_name != "保证金户") rn rn rn jfye = Convert.ToDouble(result[4].Trim()); rn dfye = Convert.ToDouble(result[5].Trim()); rn jfjs = Convert.ToDouble(result[6].Trim()); rn dfjs = Convert.ToDouble(result[7].Trim()); rn bz = result[8].Trim(); rn kmh = result[9].Trim(); rn bbh = strLine.Trim().Substring(strLine.Trim().Length - 4, 4); rnrnrnrn rnrnrn // else rn // rn rn rn // rn rn Response.Write(bbh+ " "+ result[0].ToString() +" "+ result[1].ToString() +" " + result[5].ToString()); rn Response.Write(" "); rn strLine = sr.ReadLine(); rn rn rn rn rn // Response.Write(i); rn Response.Write("aaaaaaaaaaaaaa"); rn sr.Dispose(); rn sr.Close(); rn rn Response.Write("ssssssssssss"); rn // rn // catch rn // rn // rn // rn // rnrn rnrn[/code]rnrnrn当文件加载完后,再用记事本想修改下,提示“文件被替他程序打开” 论坛

第二次打开文件无法写入。。。

06-01

[code=C/C++]rnconst Book mark = "0","0","0","0","0","0"; //empty recordrnconst char* bookDat = "D:\\book.dat";rnbool flag = true;rnrnvoid adminWidget::Initial()rnrnrn QMessageBox box;rn box.setWindowTitle("Warning");rn box.setIcon(QMessageBox::Warning);rn box.setText("If data file exists , it will delete original data.\nContinue ?");rn box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);rn if(box.exec() == QMessageBox::Yes)rn rn ofstream bdat(bookDat,ios::out | ios::binary);rn if(!bdat)rn rn QMessageBox::warning(this,tr("Warning"),tr("The file does not exist!"),QMessageBox::Yes);rn flag = false;rn return;rn rn bdat.seekp(0, ios::beg);rn bdat.write((char*) & mark, sizeof(Book));rn bdat.close();rn rnrnvoid adminWidget::Append()rnrn Book book;rn fstream bdat(bookDat,ios::in | ios::out | ios::binary);rn if(!bdat)rn rn QMessageBox::warning(this,tr("Warning"),tr("The file does not exist!"),QMessageBox::Yes);rn return;rn rn bdat.seekg(0,ios::beg);rn dorn rn bdat.read((char*)&book,sizeof(Book));rn while(!endMark(book));rn bdat.seekp(-long(sizeof(Book)),ios::cur);rn book.number = ui->bookNum->text();rn book.bookName = ui->bookName->text();rn book.Author = ui->Author->text();rn book.publish_company = ui->publishingCom->text();rn book.quantity = ui->bookQuantity->text();rn book.price = ui->price->text();rn bdat.write((char*)&book,sizeof(Book));rn bdat.write((char* )&mark,sizeof(Book));rn bdat.close();rnrn[/code]rnrn先调用Initial()初始化文件,可正常调用Append()写文件。。第二次开始就不必调用Initial(),直接调用Append()。。。出错了。。为什么?哪里有问题?望指教! 论坛

没有更多推荐了,返回首页