[MonoDevelop] mono- Creating new directory on CentOS

Amna Abbasi Amna.Abbasi at eitsec.co.uk
Thu Oct 22 02:28:08 EDT 2009


Hi All,

 

I am again here with my new problem..

Kindly help me to rectify my problem.

 

Scenario: I want to create a directory named as MyDir  in /home/
directory using C# code. I am using CentOS.

 My Code is here:

 

using System;

using System.Collections.Generic;

using System.IO;

using System.Text;

 

namespace Folder

{

    class Program

    {

        static void Main(string[] args)

        {

            // Specify the directory you want to manipulate.

            string path = @"\home\MyDir";

            try 

            {

                // Determine whether the directory exists.

                if (Directory.Exists(path)) 

                {

                    Console.WriteLine("That path exists already.");

                    Console.ReadLine();

                    return;

                }// Try to create the directory.

                DirectoryInfo di = Directory.CreateDirectory(path);

                Console.WriteLine("The directory was created
successfully at {0}.", Directory.GetCreationTime(path));

                Console.ReadLine();

            }

            catch (Exception e) 

            {

                Console.WriteLine("The process failed: {0}",
e.ToString());

                Console.ReadLine();

            } 

            finally {}

        }

    }

}

 

I compile my code like in this way:

[localdomain Folder]# gmcs Program.cs -r:System.dll

 

Compiling gives:

Program.cs(23,31): warning CS0219: The variable `di' is assigned but its
value is never used

Compilation succeeded - 1 warning(s)

 

When I run My Code using mono like:

 

[localdomain Folder]# mono Program.exe                                 

 

Its Gives:

 

The process failed: System.IO.IOException: Win32 IO returned 25. Path:
\home\MyDir

  at System.IO.Directory.Exists (System.String path) [0x00000]

  at Folder.Program.Main (System.String[] args) [0x00000]

 

when I run my code on windows machine with different dir path i.e.
c:\MyDir, its working fine.

 

Kindly help me..

 

Thanks A lot....

 

 



LEGAL DISCLAIMER
This e-mail is confidential and is for the use of the intended addressee only.  If you are not the 
intended addressee, you may not copy, disseminate or otherwise act on this e-mail or its contents. 
Please contact the sender as quickly as possible. No email received from ITSec or its subsidiaries 
may bind the company in any contract or grant any rights to any recipient or third party.

The views of the author do not necessarily reflect those of the company. http://www.eitsec.co.uk


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monodevelop-list/attachments/20091022/a73b8249/attachment-0001.html 


More information about the Monodevelop-list mailing list