Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User jiten_shah18's Avatar
    Join Date
    Apr 2009
    Posts
    36
    import codecs
    import os, os.path

    path1 = u"C:\\Data\\MyApp\\temp.ini"

    newline = "\n"

    def init_settings():
    f = codecs.open(path1, 'w', 'utf_8')
    settings = "variable_1" + newline
    settings += "variable_2" + newline
    settings += "variable_3" + newline
    f.write(settings)
    f.close()



    def mk_dir():
    if not os.path.exists(path1):
    os.makedirs(path1)



    mk_dir()
    init_settings()


    problem: the directory along with file is getting created but there is no data inside,
    emulator gives an IO error -Permission denied

  2. #2
    Nokia Developer Moderator bogdan.galiceanu's Avatar
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471
    That's because you're creating the directory named temp.ini, and then trying to write to it as if it were a file. So call os.makedirs with the path C:\\Data\\MyApp, as C:\\Data\\MyApp\\temp.ini is the path of the file.

    And please use the CODE tags when posting code (the button with the # symbol on it in the post editor). That keeps the code indented and easy to read.

  3. #3
    Registered User jiten_shah18's Avatar
    Join Date
    Apr 2009
    Posts
    36
    thanx for ur help,it worked

    can you tell me why it is creating only C:\MyApp folder instead of C:\Data\MyApp

  4. #4
    Nokia Developer Moderator bogdan.galiceanu's Avatar
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471
    That's strange... If you use os.makedirs("C:\\Data\\MyApp") it should create the folder C:\Data\MyApp. That's what it did when I tried it.

  5. #5
    Nokia Developer Expert mahesh.sayibabu's Avatar
    Join Date
    Apr 2007
    Posts
    131
    Quote Originally Posted by jiten_shah18 View Post
    can you tell me why it is creating only C:\MyApp folder instead of C:\Data\MyApp
    Are you sure that it has created C:\MyApp folder instead of C:\Data\MyApp ?
    You can check using
    Code:
    import os
    os.listdir('c:')
    os.listdir('c:\\Data')
    Some file browsers might show 'c:\Data' directly when you select phone memory. Hope this is one of such case.

  6. #6
    Registered User jiten_shah18's Avatar
    Join Date
    Apr 2009
    Posts
    36
    hello mahesh.sayibabu,
    yeah i am sure its creating c:\Myapp instead of c:\Data\Myapp
    and even the code given by u has no output may i know what is the reason?

  7. #7
    Nokia Developer Expert mahesh.sayibabu's Avatar
    Join Date
    Apr 2007
    Posts
    131
    Check with this code. It is tested on E71 with PyS60 1.9.6
    The directory, file and the file contents are created as expected.

    Code:
    import codecs
    import os, os.path
    
    dir_path = u"C:\\Data\\MyApp"
    file = "temp.ini"
    newline = "\n"
    
    
    def init_settings():
        f = codecs.open(os.path.join(dir_path, file), 'w', 'utf_8')
        settings = "variable_1" + newline
        settings += "variable_2" + newline
        settings += "variable_3" + newline
        f.write(settings)
        f.close()
    
    
    def mk_dir():
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)
    
    
    mk_dir()
    init_settings()

Similar Threads

  1. Cannot create sis package?
    By gomcoite in forum Themes/Carbide.ui
    Replies: 4
    Last Post: 2008-09-27, 17:54
  2. Error in packaging process :(
    By a-eqla3 in forum Themes/Carbide.ui
    Replies: 2
    Last Post: 2008-07-30, 22:03
  3. Error in packaging process :(
    By a-eqla3 in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2008-07-24, 20:33
  4. ERROR IN CREATING THEME
    By ssmantri in forum Themes/Carbide.ui
    Replies: 5
    Last Post: 2008-05-29, 20:58
  5. Creating a directory in a root directory
    By ajitnair in forum Mobile Java General
    Replies: 3
    Last Post: 2007-11-07, 15:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved