×

Discussion Board

Results 1 to 7 of 7

Thread: Folder Creation

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    10

    Folder Creation

    Hello all,
    I am developing an application in which i want to create seperate folder for my application.
    I am using code below but it's not working.Plz help me.

    FileConnection conn;
    try
    {
    conn = (FileConnection)Connector.open("file://localhost/E:/abc");
    if(!conn.exists())
    {
    conn.mkdir();
    }
    }
    catch(IOException e){}

    Here "abc" is folder name which i want to create.
    Thanks in advance.

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: Folder Creation

    This is an example for writing an image file (provided that you have its byte array imgdata available in memory):

    Code:
    FileConnection w=(FileConnection) Connector.open("file:///E:/Testapp1/",Connector.READ_WRITE);		
    //Creates the folder	
    w.mkdir();
    w.close();
    			
    FileConnection wf=(FileConnection) Connector.open("file:///E:/Testapp1/image1.jpg",Connector.READ_WRITE);
    			if(!wf.exists())
    			{
    				//Creates the file
                                                                    wf.create();
    				System.out.println("Created!");
    			}
    			else
    			{
    				System.out.println("Already exists!");
    			}
    			OutputStream fos=wf.openOutputStream();
    			fos.write(imgdata);
    			fos.flush();
    			fos.close();
    			wf.close();

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    11

    Re: Folder Creation

    i want to create seperate folder for my application
    Did you mean that you want to create a folder that only can be accessed by your application and not be other applications?

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    11

    Re: Folder Creation

    Quote Originally Posted by rbangar30 View Post
    Hello all,
    I am developing an application in which i want to create seperate folder for my application.
    I am using code below but it's not working.Plz help me.

    FileConnection conn;
    try
    {
    conn = (FileConnection)Connector.open("file://localhost/E:/abc");
    if(!conn.exists())
    {
    conn.mkdir();
    }
    }
    catch(IOException e){}

    Here "abc" is folder name which i want to create.
    Thanks in advance.
    Try removing localhost i.e. ("file:///E:/abc");

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    10

    Re: Folder Creation

    Quote Originally Posted by SmartPhoneEra View Post
    Did you mean that you want to create a folder that only can be accessed by your application and not be other applications?
    Nothing like that,I just want to create folder from my application where I can save my files which will be accessible to user.

  6. #6
    Registered User
    Join Date
    Oct 2011
    Posts
    10

    Re: Folder Creation

    Quote Originally Posted by skalogir View Post
    This is an example for writing an image file (provided that you have its byte array imgdata available in memory):

    Code:
    FileConnection w=(FileConnection) Connector.open("file:///E:/Testapp1/",Connector.READ_WRITE);		
    //Creates the folder	
    w.mkdir();
    w.close();
    			
    FileConnection wf=(FileConnection) Connector.open("file:///E:/Testapp1/image1.jpg",Connector.READ_WRITE);
    			if(!wf.exists())
    			{
    				//Creates the file
                                                                    wf.create();
    				System.out.println("Created!");
    			}
    			else
    			{
    				System.out.println("Already exists!");
    			}
    			OutputStream fos=wf.openOutputStream();
    			fos.write(imgdata);
    			fos.flush();
    			fos.close();
    			wf.close();

    I don't want to write an image file,instead I want create folder for that image file.In your ex. its "Testapp1".

  7. #7
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: Folder Creation

    The first three lines create the folder. You might also need the following lines, that show how to save a binary file inside the folder, that you have just created.

Similar Threads

  1. local folder creation, app crashes
    By yahoo2010 in forum Symbian
    Replies: 8
    Last Post: 2010-12-28, 19:58
  2. folder creation fails on N95
    By jvinjam in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 5
    Last Post: 2009-02-05, 18:31
  3. Replies: 4
    Last Post: 2007-08-13, 09:22
  4. Folder creation
    By rathodavinash in forum Symbian
    Replies: 2
    Last Post: 2005-08-20, 17:02
  5. creation of a folder to include lib files
    By symashi in forum Symbian
    Replies: 0
    Last Post: 2005-05-13, 07:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •