private bool writeInResources()
{
IResourceWriter writer = null;
try
{
writer = new ResourceWriter(@"myResources.resources");
writer.AddResource("day1", Constant.arrayMon);
writer.AddResource("day6", Constant.arraySat);
writer.AddResource("day7", Constant.arraySun);
writer.AddResource("day5", Constant.arrayFri);
writer.AddResource("day4", Constant.arrayThurs);
writer.AddResource("day3", Constant.arrayWed);
writer.AddResource("day2", Constant.arrayTues);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return false;
}
finally
{
if(writer !=null)
writer.Close();
}
return true;
}
为什么经常抛出这样的异常:
文件“E:\visualstudio\SBMProj\SBMProj\bin\Debug\myResources.resources”正由另一进程使用,因此该进程无法访问此文件以下是读的 private List<int> readOutResources()
{
ResourceManager rm = null;
List<int> l = null;
try
{
rm = ResourceManager.CreateFileBasedResourceManager("myResources", "/", null);
if (rm == null) return null;
l = rm.GetObject("day" + dayOfWeek.ToString()) as List<int>;
}
catch (Exception e)
{
return null;
} return l;
再也没有其他地方使用了,有时候写正常,有时候写就抛那个异常,为什么啊
{
IResourceWriter writer = null;
try
{
writer = new ResourceWriter(@"myResources.resources");
writer.AddResource("day1", Constant.arrayMon);
writer.AddResource("day6", Constant.arraySat);
writer.AddResource("day7", Constant.arraySun);
writer.AddResource("day5", Constant.arrayFri);
writer.AddResource("day4", Constant.arrayThurs);
writer.AddResource("day3", Constant.arrayWed);
writer.AddResource("day2", Constant.arrayTues);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return false;
}
finally
{
if(writer !=null)
writer.Close();
}
return true;
}
为什么经常抛出这样的异常:
文件“E:\visualstudio\SBMProj\SBMProj\bin\Debug\myResources.resources”正由另一进程使用,因此该进程无法访问此文件以下是读的 private List<int> readOutResources()
{
ResourceManager rm = null;
List<int> l = null;
try
{
rm = ResourceManager.CreateFileBasedResourceManager("myResources", "/", null);
if (rm == null) return null;
l = rm.GetObject("day" + dayOfWeek.ToString()) as List<int>;
}
catch (Exception e)
{
return null;
} return l;
再也没有其他地方使用了,有时候写正常,有时候写就抛那个异常,为什么啊
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货