Using file manger new directory not working? [duplicate]












1
















This question already has an answer here:




  • Create Directory in Swift 3.0

    4 answers



  • iOS9 Swift File Creating NSFileManager.createDirectoryAtPath with NSURL

    3 answers




Here is my code, but this code is not working is return me an error for permission.



   let fileManager = FileManager.default

// Create 'subfolder' directory

do {
try fileManager.createDirectory(atPath: "subfolder", withIntermediateDirectories: true, attributes: nil)
}
catch let error as NSError {
print("Ooops! Something went wrong: (error)")
}

let documentsUrl:URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL!

print("(documentsUrl)")


** error **




oops! Something went wrong: Error Domain=NSCocoaErrorDomain Code=513
"You don’t have permission to save the file “subfolder”."











share|improve this question















marked as duplicate by Kamran, Dharmesh ios
Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 6:57


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.























    1
















    This question already has an answer here:




    • Create Directory in Swift 3.0

      4 answers



    • iOS9 Swift File Creating NSFileManager.createDirectoryAtPath with NSURL

      3 answers




    Here is my code, but this code is not working is return me an error for permission.



       let fileManager = FileManager.default

    // Create 'subfolder' directory

    do {
    try fileManager.createDirectory(atPath: "subfolder", withIntermediateDirectories: true, attributes: nil)
    }
    catch let error as NSError {
    print("Ooops! Something went wrong: (error)")
    }

    let documentsUrl:URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL!

    print("(documentsUrl)")


    ** error **




    oops! Something went wrong: Error Domain=NSCocoaErrorDomain Code=513
    "You don’t have permission to save the file “subfolder”."











    share|improve this question















    marked as duplicate by Kamran, Dharmesh ios
    Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 26 '18 at 6:57


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





















      1












      1








      1









      This question already has an answer here:




      • Create Directory in Swift 3.0

        4 answers



      • iOS9 Swift File Creating NSFileManager.createDirectoryAtPath with NSURL

        3 answers




      Here is my code, but this code is not working is return me an error for permission.



         let fileManager = FileManager.default

      // Create 'subfolder' directory

      do {
      try fileManager.createDirectory(atPath: "subfolder", withIntermediateDirectories: true, attributes: nil)
      }
      catch let error as NSError {
      print("Ooops! Something went wrong: (error)")
      }

      let documentsUrl:URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL!

      print("(documentsUrl)")


      ** error **




      oops! Something went wrong: Error Domain=NSCocoaErrorDomain Code=513
      "You don’t have permission to save the file “subfolder”."











      share|improve this question

















      This question already has an answer here:




      • Create Directory in Swift 3.0

        4 answers



      • iOS9 Swift File Creating NSFileManager.createDirectoryAtPath with NSURL

        3 answers




      Here is my code, but this code is not working is return me an error for permission.



         let fileManager = FileManager.default

      // Create 'subfolder' directory

      do {
      try fileManager.createDirectory(atPath: "subfolder", withIntermediateDirectories: true, attributes: nil)
      }
      catch let error as NSError {
      print("Ooops! Something went wrong: (error)")
      }

      let documentsUrl:URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL!

      print("(documentsUrl)")


      ** error **




      oops! Something went wrong: Error Domain=NSCocoaErrorDomain Code=513
      "You don’t have permission to save the file “subfolder”."






      This question already has an answer here:




      • Create Directory in Swift 3.0

        4 answers



      • iOS9 Swift File Creating NSFileManager.createDirectoryAtPath with NSURL

        3 answers








      ios swift






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 15:48









      rmaddy

      245k27324388




      245k27324388










      asked Nov 26 '18 at 6:39









      Digvijay GidaDigvijay Gida

      127




      127




      marked as duplicate by Kamran, Dharmesh ios
      Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 26 '18 at 6:57


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Kamran, Dharmesh ios
      Users with the  ios badge can single-handedly close ios questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 26 '18 at 6:57


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          1














          I think, you should provide the full path of your new directory as like below.



          let applicationDocumentsDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last!

          let fileManager = FileManager.default

          do {
          try fileManager.createDirectory(atPath: applicationDocumentsDirectory + "/subfolder", withIntermediateDirectories: true, attributes: nil)
          }
          catch let error as NSError {
          print("Ooops! Something went wrong: (error)")
          }





          share|improve this answer
























          • you have idea about different-different type collage frame in iOS ? @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 6:00













          • thanks @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 12:53






          • 1





            You are welcome!

            – Natarajan
            Nov 27 '18 at 13:49


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I think, you should provide the full path of your new directory as like below.



          let applicationDocumentsDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last!

          let fileManager = FileManager.default

          do {
          try fileManager.createDirectory(atPath: applicationDocumentsDirectory + "/subfolder", withIntermediateDirectories: true, attributes: nil)
          }
          catch let error as NSError {
          print("Ooops! Something went wrong: (error)")
          }





          share|improve this answer
























          • you have idea about different-different type collage frame in iOS ? @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 6:00













          • thanks @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 12:53






          • 1





            You are welcome!

            – Natarajan
            Nov 27 '18 at 13:49
















          1














          I think, you should provide the full path of your new directory as like below.



          let applicationDocumentsDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last!

          let fileManager = FileManager.default

          do {
          try fileManager.createDirectory(atPath: applicationDocumentsDirectory + "/subfolder", withIntermediateDirectories: true, attributes: nil)
          }
          catch let error as NSError {
          print("Ooops! Something went wrong: (error)")
          }





          share|improve this answer
























          • you have idea about different-different type collage frame in iOS ? @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 6:00













          • thanks @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 12:53






          • 1





            You are welcome!

            – Natarajan
            Nov 27 '18 at 13:49














          1












          1








          1







          I think, you should provide the full path of your new directory as like below.



          let applicationDocumentsDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last!

          let fileManager = FileManager.default

          do {
          try fileManager.createDirectory(atPath: applicationDocumentsDirectory + "/subfolder", withIntermediateDirectories: true, attributes: nil)
          }
          catch let error as NSError {
          print("Ooops! Something went wrong: (error)")
          }





          share|improve this answer













          I think, you should provide the full path of your new directory as like below.



          let applicationDocumentsDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last!

          let fileManager = FileManager.default

          do {
          try fileManager.createDirectory(atPath: applicationDocumentsDirectory + "/subfolder", withIntermediateDirectories: true, attributes: nil)
          }
          catch let error as NSError {
          print("Ooops! Something went wrong: (error)")
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 6:53









          NatarajanNatarajan

          2,29131126




          2,29131126













          • you have idea about different-different type collage frame in iOS ? @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 6:00













          • thanks @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 12:53






          • 1





            You are welcome!

            – Natarajan
            Nov 27 '18 at 13:49



















          • you have idea about different-different type collage frame in iOS ? @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 6:00













          • thanks @Natarajan

            – Digvijay Gida
            Nov 27 '18 at 12:53






          • 1





            You are welcome!

            – Natarajan
            Nov 27 '18 at 13:49

















          you have idea about different-different type collage frame in iOS ? @Natarajan

          – Digvijay Gida
          Nov 27 '18 at 6:00







          you have idea about different-different type collage frame in iOS ? @Natarajan

          – Digvijay Gida
          Nov 27 '18 at 6:00















          thanks @Natarajan

          – Digvijay Gida
          Nov 27 '18 at 12:53





          thanks @Natarajan

          – Digvijay Gida
          Nov 27 '18 at 12:53




          1




          1





          You are welcome!

          – Natarajan
          Nov 27 '18 at 13:49





          You are welcome!

          – Natarajan
          Nov 27 '18 at 13:49





          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin