[MonoDevelop] mono- Creating new directory on CentOS

Karthikeyan R karthikeyan_r at spanservices.com
Tue Oct 27 08:38:46 EDT 2009

Path suppose to be,

string path =  @"/home/MyDir";

Karthikeyan R

-----Original Message-----
From: monodevelop-list-bounces at lists.ximian.com [mailto:monodevelop-list-bounces at lists.ximian.com] On Behalf Of Amna Abbasi
Sent: Thursday, October 22, 2009 11:58 AM
To: monodevelop-list at lists.ximian.com
Subject: [MonoDevelop] mono- Creating new directory on CentOS

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";



                // Determine whether the directory exists.

                if (Directory.Exists(path)) 


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



                }// Try to create the directory.

                DirectoryInfo di = Directory.CreateDirectory(path);

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



            catch (Exception e) 


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



            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....




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



This email message and all attachments are  confidential and may contain information that
is privileged,  confidential or exempt from  disclosure under applicable law.  If you are
not  the intended  recipient,  you  are notified  that any dissemination, distribution or 
copying  of this email  is strictly prohibited. If you have received this email in error, 
please notify us immediately by return email or to mailadmin at spanservices.com and destroy 
the original message.

Opinions, conclusions, and other  information in  this message that  do not relate to the 
official business of SPAN, shall be understood to be neither given nor endorsed by SPAN.

More information about the Monodevelop-list mailing list