Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,

i have a button which when pressed will run this bit of code, what this does is it gets the requested path and tries to find a filename "txtDealerCode.Text + "*.wav" but all i get is "1111*.wav", but i need it so that the * will mean anything so for example it might return "1111abc" or "1111987" is that possible?? i have seen it where people use 1111.* to get the file with * being the filetype but isit possible to do it half way through?
C#
UserDirectory uDirectory = new UserDirectory();
string path = uDirectory.GetUserDirectory(txtProjectReference.Text, "CheckDirectory");
string fileName = txtDealerCode.Text + "*.wav";
string file = path + fileName;
Process.Start(file);



Thanks,
Bunker
Posted
Comments
shreekar 12-Mar-12 14:31pm    
As a thumb rule, anything you pass to Process.Start should execute successfully from Start->Run of the machine you are trying to run it on.

string[] files = Directory.GetFiles(path, txtDealerCode.Text + "*.wav");
 
Share this answer
 
v2
You're code is trying to launch a process with the filename with a wildcard in it. You can't do that. Wildcards are not allowed in filepath describing the process to launch.

If this is what you really want to do, you have to use one of the GetFiles methods and enumerate over this list and use Process.Start on each of these filenames seperately. Though, I really cringe when I think about the possiblity of having 100 files returned.
 
Share this answer
 
 
Share this answer
 
v2
Comments
BunkerBilly 12-Mar-12 12:44pm    
what do u mean by "Use regular expressions along with FileInfo/DirectoryInfo classes.2" ???

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900