|
Apparently the answer is to close down the project and open it again and it works fine.
Vs just wanted to be awkward.
|
|
|
|
|
Sometimes rebuilding helps as well with these weird errors.
I get them a lot when using usercontrols.
|
|
|
|
|
Yeah that did work although there is another error:
Warning 1 Object reference not set to an instance of an object.
which appears every now and again and prevents me seeing the form in design view.
|
|
|
|
|
You don't happen to be using vs2005
I noticed I have it there more than in vs2008 (can't remember having it in 2008 ever actually)
When rebuilding the project its best to have the designer and maybe even the code closed.
Don't know why it happens, all I can think off is that it's a bug.
|
|
|
|
|
Yes it is strange.
will have to try that
Hopefully its a bug with vs and not my code.
Thanx for the help
|
|
|
|
|
is it an error or a warning?
Generally I see those as a warning when I did something like:
int my_int;
instead of
int my_int = 0;
it warns you in order to avoid being null when running a statement later.
hope this helps.
|
|
|
|
|
Hi all,
i can use something like the code below to get all the directory within a given folder.
DirectoryInfo di = new DirectoryInfo(@"C:\");
foreach (DirectoryInfo d in di.GetDirectories("*.*", SearchOption.AllDirectories))
{
Console.WriteLine(d.Name);
}
but as soon as i hit a folder i dont have access to it crashes.
is there anyway i can perform the same action but get it to skip folder i don't have access too?
Many Thanks,
Phil
|
|
|
|
|
|
use try-catch inside the loop. That is what I do.
BTW: .NET 4.0 will offer better methods to enumerate files/folders, without requiring a (possibly huge) array, so one will be able to really use the recursive mode.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
That will not work. The exception will occur while executing the GetDirectories method itself and control will never go inside the try/catch .
|
|
|
|
|
It works for me, I am listing all files/folders of any device I choose (both XP and Vista).
If GetDirectories() and GetFiles() would not cope with inaccessible files and folders, they would be completely useless, wouldn't they?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
In XP SP2, I created a folder(c:\TestFolder) and "denied" all the permissions under security tab. GetDirectories method itself will throw exception. Control never came to try/catch. See my code:
DirectoryInfo dirInfo = new DirectoryInfo(@"C:\");
foreach (DirectoryInfo dir in dirInfo.GetDirectories("*.*", SearchOption.AllDirectories)) {
try {
}
catch {
}
}
|
|
|
|
|
That is new to me. I'll have to investigate.
And what is your solution?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Never faced this issue, so far. If I do, I would go for Linq. May be something along the lines of this[^] approach.
If it .Net 2.0, Linq bridge[^] might save me.
|
|
|
|
|
AFAIK there is no such option present. You will have to write your own method to do this.
|
|
|
|
|
Cool, thanks guy, i thought there would be an easy option!!
|
|
|
|
|
I implemented some sort of Beep functionality to my Application, but I don't hear a sound:
[DllImport("kernel32.dll")]
public static extern bool Beep(int Frequenz, int Dauer);
public static void Alarm()
{
for (int i = 0; i < 3; i++)
{
Beep(500, 1000);
Beep(1000, 1000);
}
}
public static void Beep()
{
Beep(1000, 1000);
}
On my testform I click a Button to test this:
private void button6_Click(object sender, EventArgs e)
{
Program.Alarm();
}
PC Speaker is ok, it beeps at startup. I am using Vista 64bit. Any suggestions?
|
|
|
|
|
Try adding a reference to the Microsoft.VisualBasic assembly and then, as if by magic, you can call:
Microsoft.VisualBasic.Interaction.Beep();
Can you tell what it is yet?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
No need for the VB assembly, it's already there in System.Console class.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Serves me right for relying on MSDN for information
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Needing VB to make C# beep a little would be completely unacceptable.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I'm not sure why it doesn't work for you - I'm sure I've used it before.
Quickie solution is to use Console.Beep
Console.Beep(440, 1000);
[Edit]I've just tried your code and it works perfectly, although I would use standard musical frequencies[^]. Person's with a sensitive musical disposition such as those with perfect or good relative pitch could find 500Hz/1KHz quite painful![/Edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
DaveyM69 wrote: quite painful!
Ehhhhxcellent...
|
|
|
|
|
gehbitte wrote: public static void Alarm()
{
for (int i = 0; i < 3; i++)
{
Beep(500, 1000);
Beep(1000, 1000);
}
}
You are not bothering to check the return value from the API. Can you check it to verify that the function succeeds?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
long time ago I started using this P/Invoke code:
[DllImport("user32.dll")]
public static extern bool MessageBeep(int type);
Not sure I still have to do it this way though.
BTW: Make sure through Control Panel Sounds the right sounds are installed.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|