[MonoDevelop] Im learning to program and I'm getting an error i cant understand :(

Connel connelhooley at googlemail.com
Sun Apr 4 16:14:41 EDT 2010


Thanks for your help Alan but the line that is reporting an error does
contain brackets :s below is the line that is a method but is supposedly
being used like a property according to MonoDevelop:

string strFileName = Path.GetFileName(strFile);

I just really don't understand where I'm going wrong. strFile contains a
path to a file. I want to create a string that only contains the file's name
called strFileName. Am I not allowed to but a string inside the brackets?

Thanks for all the replies everyone :D


Alan McGovern wrote:
> 
> Somewhere you're using a method as if it were a property. You've
> written something like:
> 
> Console.WriteLine;
> 
> instead of
> 
> Console.WriteLine ();
> 
> Alan.
> 
> On Sun, Apr 4, 2010 at 7:13 PM, Connel <connelhooley at googlemail.com>
> wrote:
>>
>>
>> Buttink wrote:
>>>
>>> hmmmm............. can you put whats before that? I tried, but I cant
>>> recreate it.
>>>
>>
>> Yeah sure below is all my code. Just in case you need to know my GUI is
>> made
>> up of two file chooser buttons (fchDestination and fchTarget) and a
>> button
>> (btnSync). At the moment the program is just supposed to copy files from
>> one
>> folder to another but only if the file does not exist in the other folder
>> or
>> the file in the other folder is older. I am using OpenSuse 11.2 and
>> MonoDevelop 2.2. Thanks for the quick reply! Its really bugging me lol :)
>>
>> using System;
>> using System.IO;
>> using Gtk;
>>
>> public partial class MainWindow : Gtk.Window
>> {
>>
>>        public MainWindow () : base(Gtk.WindowType.Toplevel)
>>        {
>>                Build ();
>>        }
>>
>>        protected void OnDeleteEvent (object sender, DeleteEventArgs a)
>>        {
>>                Application.Quit ();
>>                a.RetVal = true;
>>        }
>>
>>        protected virtual void OnBtnSyncClicked (object sender,
>> System.EventArgs e)
>>        {
>>                Sync(fchTarget.CurrentFolder);
>>        }
>>
>>        protected void Sync (string strCurrentDirectory)
>>        {
>>                //string array of all the files in directory
>>                string[] staAllFiles =
>> Directory.GetFiles(strCurrentDirectory);
>>
>>                //loop over each file in directory
>>                foreach (string strFile in staAllFiles)
>>                {
>>                        //string of just the files name and not its path
>>                        string strFileName = Path.GetFileName(strFile);
>>
>>                        //tests if file does not exist in destination
>> folder
>>                        if
>> (!File.Exists(fchDestination.CurrentFolder+strFileName)) {
>>                                //if file does not exist copy it to
>> destination folder, the true below
>> means overwrite if file already exists
>>                                File.Copy (strFile,
>> fchDestination.CurrentFolder+strFileName, true);
>>                        }
>>
>>                        //tests if file does exist in destination folder
>>                        if
>> (File.Exists(fchDestination.CurrentFolder+strFileName)) {
>>                                //long (number) that contains date of last
>> write time of target file
>>                                long lngTargetFileDate =
>> File.GetLastWriteTime(strFile).ToFileTime();
>>                                //long (number) that contains date of last
>> write time of destination
>> file
>>                                long lngDestinationFileDate =
>> File.GetLastWriteTime(fchDestination.CurrentFolder+strFileName).ToFileTime();
>>
>>                                //tests is target file is newer than
>> destination file
>>                                if (lngTargetFileDate >
>> lngDestinationFileDate) {
>>                                        File.Copy (strFile,
>> fchDestination.CurrentFolder+strFileName, true);
>>                                }
>>                                //tests is target file is older than
>> destination file
>>                                if (lngTargetFileDate <
>> lngDestinationFileDate) {
>>                                        File.Copy (strFile,
>> fchTarget.CurrentFolder+strFileName, true);
>>                                }
>>                        }
>>
>>                }
>>
>>        }
>>  }
>>
>> --
>> View this message in context:
>> http://n4.nabble.com/Im-learning-to-program-and-I-m-getting-an-error-i-cant-understand-tp1751009p1751039.html
>> Sent from the Mono - MonoDevelop IDE mailing list archive at Nabble.com.
>> _______________________________________________
>> Monodevelop-list mailing list
>> Monodevelop-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/monodevelop-list
>>
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-list
> 
> 

-- 
View this message in context: http://n4.nabble.com/Im-learning-to-program-and-I-m-getting-an-error-i-cant-understand-tp1751009p1751117.html
Sent from the Mono - MonoDevelop IDE mailing list archive at Nabble.com.


More information about the Monodevelop-list mailing list