Click here to Skip to main content
15,940,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all.
I have a program which when i first load my form it open a specific file contains text document .
i put this file in the release file and i use
string[] LoadFile = Directory.GetFiles("SpamWords", "*.txt");
which SpamWords is the name of the file.
but every time the compiler go through this sentence it goes to designer and the dispose become true,and the rest of the code in the load function won't complete....

What can i do??
i just want to open this folder once the form load

thx
Posted

1 solution

The first parameter is the location to search in. The second parameter is the search pattern. You were telling the computer to look in "SpamWords" which should be a sub-folder within the folder that your application is running and return any file with the txt extension. It probably threw an error saying that SpamWords is not a valid directory. You didn't actually tell us what the error was though...just that the program quit on that line.

You said
/-/ AL 3 wrote:
SpamWords is the name of the file.


Did you mean SpamWords is the name of the folder? First just try Directory.Exists("SpamWords") If that returns false, then the SpamWords folder is not where you think it is. That would be the only reason that I could see it having a problem
 
Share this answer
 

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