Skip to content

Instantly share code, notes, and snippets.

@erdemarslan
Created September 2, 2018 21:45
Show Gist options
  • Select an option

  • Save erdemarslan/8d2b116c86ff755c9d447e02b6ddd74c to your computer and use it in GitHub Desktop.

Select an option

Save erdemarslan/8d2b116c86ff755c9d447e02b6ddd74c to your computer and use it in GitHub Desktop.
let filemanager = FileManager.default
var isDir : ObjCBool = false
let filename = "test"
let fileExtension = "txt"
var dir = try? filemanager.url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
dir!.appendPathComponent(filename)
dir!.appendPathExtension(fileExtension)
if filemanager.fileExists(atPath: dir!.path, isDirectory: &isDir) {
if isDir.boolValue {
print("var ve bu bir klasör")
} else {
print("var ve bu bir dosya")
}
} else {
print("dosya veya klasör yok!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment