InitializeComponent();
timer.Tick += new EventHandler(timer_Tick);
timer.Interval = new TimeSpan(0, 0, 3);
timer.Start();
}
BitmapImage bitmap;
FileStream m_ImageStream;
Liststring imgPath = new Liststring
int imgNum = 0;
private void ShowImage()
{
try
{
Uri xxx = new Uri(@"d:\图片\Home1.jpg");
string imageFilePath = @"d:\图片\Home1.jpg";
m_ImageStream = new FileStream(imageFilePath, FileMode.Open);
bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = m_ImageStream;
bitmap.EndInit();
image.Source = bitmap;
int i = 0;
foreach (string d in System.IO.Directory.GetFileSystemEntries(@"d:\图片", "*.JPG"))
{
if (System.IO.File.Exists(d))
{
i++;
}
}
}
catch (Exception ex)
{ }
}
private void timer_Tick(object sender, EventArgs e)
{
foreach (string d in System.IO.Directory.GetFileSystemEntries(@"d:\图片", "*.JPG"))
{
if (System.IO.File.Exists(d))
{
imgPath.Add(d);
}
}
if (m_ImageStream != null)
{
m_ImageStream.Close();
m_ImageStream.Dispose();
}
m_ImageStream = new System.IO.FileStream(imgPath[imgNum], FileMode.Open);
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = m_ImageStream;
bitmap.EndInit();
image.Source = bitmap;
imgNum++;
if (imgNum == imgPath.Count())
{
imgNum = 0;
}
}
各位大神,想问一下,程序运行老提示文件d:图片\Home1.jpg正由另一进程使用,因此无法访问此文件
2016年6月.NET技术大版内专家分月排行榜第二2016年3月.NET技术大版内专家分月排行榜第二2016年1月.NET技术大版内专家分月排行榜第二2015年12月.NET技术大版内专家分月排行榜第二2015年2月.NET技术大版内专家分月排行榜第二2015年1月.NET技术大版内专家分月排行榜第二2014年11月.NET技术大版内专家分月排行榜第二2014年5月.NET技术大版内专家分月排行榜第二2014年4月.NET技术大版内专家分月排行榜第二2012年2月多媒体/设计/Flash/Silverlight开发大版内专家分月排行榜第二
2016年5月.NET技术大版内专家分月排行榜第三2016年4月.NET技术大版内专家分月排行榜第三2016年2月.NET技术大版内专家分月排行榜第三2015年10月.NET技术大版内专家分月排行榜第三2015年9月.NET技术大版内专家分月排行榜第三2015年7月.NET技术大版内专家分月排行榜第三2015年6月.NET技术大版内专家分月排行榜第三2015年5月.NET技术大版内专家分月排行榜第三2015年4月.NET技术大版内专家分月排行榜第三2014年12月.NET技术大版内专家分月排行榜第三2014年10月.NET技术大版内专家分月排行榜第三2014年9月.NET技术大版内专家分月排行榜第三2014年1月.NET技术大版内专家分月排行榜第三2013年12月.NET技术大版内专家分月排行榜第三2013年10月.NET技术大版内专家分月排行榜第三2013年5月.NET技术大版内专家分月排行榜第三2011年9月.NET技术大版内专家分月排行榜第三2011年2月.NET技术大版内专家分月排行榜第三2010年2月.NET技术大版内专家分月排行榜第三
如果你不能先把文件内容读到一个 StreamMemory 再来处理(并且同时及时关闭文件),那么在读取之前就应该先复制到一个“临时文件”中,然后读取临时文件。
每天回帖即可获得10分可用分!小技巧:教您如何更快获得可用分
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN用户行为准则,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。