本文介绍了没有进程时出现IOException错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我正在一个打算租车的网站上工作.我已经创建了SQL数据库并且可以正常工作,但是当我创建一个民意调查并尝试从文件中读取时,我得到IOException-它正在被另一个进程使用.有什么办法可以解决此问题,还是应该在数据库中创建另一个表?

P.S.这是我的代码:

Hello,
I am working on a website that is soposed to rent cars. I have created SQL Database and it works, but when i create a poll, and try to read from a file, i get IOException - It is being used by another process. Is there any way to fix this, or should I create another table in the database?

P.S. Here''s my code:

public enum Answer
{ Yes, StillLooking, Close, No }
.
.
.
        [WebMethod]
        public int Count(Answer a)
        {
            StreamReader sr = new StreamReader(Server.MapPath(String.Format("{0}.txt", a)));
            return int.Parse(sr.ReadToEnd());
        }
        [WebMethod]
        public void AddVote(Answer a)
        {
            StreamWriter sw = new StreamWriter(Server.MapPath(String.Format("{0}.txt", a)));
            int num = Count(a);
            num++;
            sw.Write(num.ToString());
            sw.Close();
        }

推荐答案


这篇关于没有进程时出现IOException错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 06:59