空路径名称是不合法的 [英] Empty Path Name Is Not Legal

查看:1491
本文介绍了空路径名称是不合法的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图编译一个小行星游戏。这几乎是工作,所有的文件都到位等等...



这个问题来当它击中这个代码。

 的FileStream myFileStream =新的FileStream(文件名,FileMode.Open,FileAccess.Read,FileShare.Read); 
串myTempFile = @F:\Documents\Junio​​r School\Computer编程(Java的1)\AsteroidsWithSound\AsteroidsWithSound\temp\mysound+ i.ToString()+.WAV ;



这给了我一个错误/警告,不知道到底是什么所谓的,但它说。



ArgumentException的是未处理。
空路径名称是不合法的。



我在网上读到这样的代码块造成这个问题,但永远无法找到一个解决方案。 。任何帮助将是真棒



编辑:文件名是在这个块定义



 字符串文件名= this.Player.FileName; 
this.Player.Open();
File.Delete(文件名);
this.isReady = TRUE;


解决方案

这表明文件名变量指的是一个空字符串。



您还没有显示设置文件名的值,但是这是位来看待。


So I'm trying to compile an Asteroids game. It's almost working, all the files are in place etc etc...

The issue comes when it hits this code.

FileStream myFileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
string myTempFile = @"F:\Documents\Junior School\Computer Programming (Java 1)\AsteroidsWithSound\AsteroidsWithSound\temp\mysound" + i.ToString() + ".wav";

It gives me an Error/Warning, not sure exactly what it is called but it says

ArgumentException was unhandled. Empty path name is not legal.

I've read online about chunks of code like this causing this issue but could never find a resolution. Any help would be awesome.

EDIT: Filename is defined in this chunk.

string filename = this.Player.FileName;
this.Player.Open("");
File.Delete(filename);
this.isReady = true;

解决方案

That suggests that the filename variable refers to an empty string.

You haven't shown the code that sets the value of filename, but that's the bit to look at.

这篇关于空路径名称是不合法的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆