Swift 3.0 FileManager.fileExists(atPath:) always return false

前端 未结 7 2125
一向
一向 2021-02-05 00:38

When I use method .fileExists(atPath:)to judge whether the file is exist in file system, the method always return false to me. I checked the file system and the fil

7条回答
  •  伪装坚强ぢ
    2021-02-05 00:53

     let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true);
        var path = paths[0] as String;
        path = path + "/YourFilePath"
        if((NSFileManager.defaultManager().fileExistsAtPath(path))) {
                 let result = NSData(contentsOfFile: filePath!)}
    

    Try the above code and check again

提交回复
热议问题