文件名字符导致开口失败:EINVAL(无效参数) [英] Filename chars cause opening failed: EINVAL (Invalid argument)

查看:285
本文介绍了文件名字符导致开口失败:EINVAL(无效参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建具有以下格式的文件名的文件:日 - 月 - 年 - HOUR:MINUTE 但是当我使用 - 或/和我收到打开失败:EINVAL 例外。我试图逃避这些字符,但没有喜悦。是否有被禁止的文件名字符的任何列表?

 字符串时间=将String.valueOf(c.get(Calendar.DAY_OF_MONTH))+ - +将String.valueOf(c.get(的Calendar.MONTH)+ 1)+ - +
               将String.valueOf(c.get(Calendar.YEAR))+ - +将String.valueOf(c.get(Calendar.HOUR))+\\\\:+将String.valueOf(c.get(Calendar.MINUTE )); bufOutstream =新的BufferedOutputStream(新的FileOutputStream(新文件(env.getExternalStorageDirectory()+/ MyApp的/+时间+ + fExtension))。);

logcat的:

  10月12日至1日:34:01.181 25839-26542 / com.example.app W / System.err的:捕获到IOException:/存储/ sdcard0 / MyApp的/ 2013年1月12日--10 \\:34.aac:打开失败:EINVAL(无效参数)


解决方案

请参考这个页面,你会发现完整列表。

http://en.wikipedia.org/wiki/Comparison_of_file_systems

虽然你的SD卡可能是内部和安装的保险丝,它可能还是FAT32文件系统。对于FAT32的有效字符(按页):

除了值0-31任何字节,127(DEL)和* /?<> \\ | +,; = [](lowcase AZ都被存储为AZ)随着VFAT LFN任何统一$ C $ç除了NUL [14] [15]

I'd like to create a file with the filename in the following format: DAY-MONTH-YEAR--HOUR:MINUTE but when I use -- or/and : I'm getting open failed: EINVAL exception. I was trying to escape these chars but without joy. Is there any list of the forbidden filename chars?

   String time = String.valueOf(c.get(Calendar.DAY_OF_MONTH)) + "-" + String.valueOf(c.get(Calendar.MONTH) + 1) + "-" +
               String.valueOf(c.get(Calendar.YEAR)) + "--" + String.valueOf(c.get(Calendar.HOUR)) + "\\:" + String.valueOf(c.get(Calendar.MINUTE));

 bufOutstream = new BufferedOutputStream(new FileOutputStream(new File(env.getExternalStorageDirectory()+"/myapp/"+time+"."+fExtension)));

logcat:

12-01 10:34:01.181  25839-26542/com.example.app W/System.err﹕ Caught IOException: /storage/sdcard0/myapp/1-12-2013--10\:34.aac: open failed: EINVAL (Invalid argument)

解决方案

Please refer to this page, you will find the full list.

http://en.wikipedia.org/wiki/Comparison_of_file_systems

Although that your sdcard might be internal and mount as FUSE, it might be still FAT32 filesystem. The valid characters for FAT32 are (according to the page):

Any byte except for values 0-31, 127 (DEL) and: " * / : < > ? \ | + , . ; = [] (lowcase a-z are stored as A-Z). With VFAT LFN any Unicode except NUL[14][15]

这篇关于文件名字符导致开口失败:EINVAL(无效参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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