Search for a file

Search for a file, find it and make an action

Page 1 of 1

4 Replies - 1357 Views - Last Post: 06 December 2010 - 09:15 AM Rate Topic: -----

#1 emekapa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 06-December 10

Search for a file

Posted 06 December 2010 - 08:32 AM

Hi all,

I'm beggining with C# and i'm triyng to make a simple application: To search for files in a folder and to make an action...

For example, imagine a folder with 3 image and 2 other type of files ...

How can i make an action to search for files and when find that there are files, if there is an image print: there is an image, then delete it and search again if there is any more images. When images are left, search for other file type.

I've seen examples but they are all directed to windows app or forms, i want to do it in console, can someone give me some directios like wich libraries to use or examples of similar tutorials or programs?

Best Regards

Is This A Good Question/Topic? 0
  • +

Replies To: Search for a file

#2 mavarazo   User is offline

  • D.I.C Head
  • member icon

Reputation: 37
  • View blog
  • Posts: 182
  • Joined: 25-October 10

Re: Search for a file

Posted 06 December 2010 - 08:36 AM

I think you have to read about DirectoryInfo & FileInfo

This post has been edited by mavarazo: 06 December 2010 - 08:37 AM

Was This Post Helpful? 2
  • +
  • -

#3 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Search for a file

Posted 06 December 2010 - 08:37 AM

Show us what code you found for Windows Forms. Generally speaking the code will work regardless with changes only needed to made on the frontend code. Specifically changing winforms controls to Console.WriteLine commands.
Was This Post Helpful? 1
  • +
  • -

#4 emekapa   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 06-December 10

Re: Search for a file

Posted 06 December 2010 - 08:53 AM

View PostSergio Tapia, on 06 December 2010 - 07:37 AM, said:

Show us what code you found for Windows Forms. Generally speaking the code will work regardless with changes only needed to made on the frontend code. Specifically changing winforms controls to Console.WriteLine commands.


I've seen examples like this one but didn't understand the basis concept and where are the search parameters and all:
void MyMethod(string tempjobfolder)
{
string[] allfiles = Array.FindAll(Directory.GetFiles(tempjobfolder), IsNOTdotAPSIM); //where 'IsNOTdotAPSIM' = bool method(string) - see below

}

bool IsNOTdotAPSIM(string s)
{
return !s.EndsWith(".apsim");
}



This post has been edited by JackOfAllTrades: 06 December 2010 - 08:59 AM
Reason for edit:: Stripped search tags from code

Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5106
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Search for a file

Posted 06 December 2010 - 09:15 AM

Those are terrible examples. Read the links mavarazo provided, and see what you can come up with.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1