Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Search for file at run-time
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00949224
Message ID:
00949413
Views:
8
Bob,
Thanks for the reply and tip. Just a little bit of recursion and I will find that pesky file <s>.

I did a little bit more digging around in System.IO.Directory and found a method called GetFileSystemInfos(). this method seems to do what I want even without the recursion.

The .NET Framework just gets better and better the more I learn.

Einar

>Look at the System.IO.Directory class. It has an Exists method.
>
>BOb
>
>
>>Bonnie,
>>No I do not want any user interaction. I have a specific file MySpecialFile.dat (hardcoded filename) that I want to search for on local drives or on My Computer (local and network drives). The file might or might not exist. If it does exist I want to know what directory the file is in and if the file doesn't exist well then the user is SOL :)
>>
>>Some pseudo-code:
>>if (SearchForFile("mYSpecialFile.dat"))
>> Get the directory where MySpecialFile.dat is located and do my stuff
>>else
>> Tell the user in a friendly way that he/she is SOL ;)
>>
>>Hope this helps so that you can help me :)
>>
>>Thanks,
>>Einar
>>
>>
>>>Einar,
>>>
>>>Do you mean having the user select a file? If so, something like this would work:
>>>
>>>System.Windows.Forms.OpenFileDialog oSelectFile = new System.Windows.Forms.OpenFileDialog();
>>>DialogResult dr = oSelectFile.ShowDialog();
>>>
>>>if(dr == DialogResult.OK)
>>>{
>>>  // oSelectFile.FileName contains the name of the file selected.
>>>}
>>>
>>>
>>>~~Bonnie
>>>
>>>>How would I go about searching for a file on My Computer at run time?
>>>>I might want to narrow the search down to only local drives, in that case how can I get an array or collection of local drives?
>>>>
>>>>Thanks,
>>>>Einar
Semper ubi sub ubi.
Previous
Reply
Map
View

Click here to load this message in the networking platform