如果文件名由正斜杠组成,如“te/st.pdf”
[data writeToFile:@"/Documents/te/st.pdf" atomically:YES encoding:NSUTF8StringEncoding error:nil]
是否有任何解决方案而不是用其他字符替换正斜杠“/”。
最佳答案
出于某些奇怪的原因,你必须使用 \:
所以它会是
[data writeToFile:@"/Documents/te\:st.pdf" atomically:YES encoding:NSUTF8StringEncoding error:nil]
它可以工作,但编译器会提示未知的转义序列。
如果您在使用正斜杠创建文件的文件夹中执行 ls -la
,您会看到它被命名为 the:st.pdf
关于iphone - 崩溃 : if the file name consists forward slash like "te/st.pdf",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19833372/