Click here to Skip to main content
15,867,568 members
Home / Discussions / C#
   

C#

 
GeneralRe: FileSystemWatcher Problem Pin
Garth J Lancaster20-Feb-16 18:37
professionalGarth J Lancaster20-Feb-16 18:37 
AnswerRe: FileSystemWatcher Problem Pin
Garth J Lancaster20-Feb-16 18:42
professionalGarth J Lancaster20-Feb-16 18:42 
AnswerRe: FileSystemWatcher Problem Pin
Gerry Schmitz21-Feb-16 9:11
mveGerry Schmitz21-Feb-16 9:11 
GeneralRe: FileSystemWatcher Problem Pin
Kevin Marois22-Feb-16 6:30
professionalKevin Marois22-Feb-16 6:30 
GeneralRe: FileSystemWatcher Problem Pin
Gerry Schmitz22-Feb-16 6:57
mveGerry Schmitz22-Feb-16 6:57 
GeneralRe: FileSystemWatcher Problem Pin
Kevin Marois22-Feb-16 7:01
professionalKevin Marois22-Feb-16 7:01 
GeneralRe: FileSystemWatcher Problem Pin
Gerry Schmitz22-Feb-16 7:33
mveGerry Schmitz22-Feb-16 7:33 
GeneralRe: FileSystemWatcher Problem Pin
Kevin Marois22-Feb-16 7:43
professionalKevin Marois22-Feb-16 7:43 
Ya but the problem is that you never really know what event are going to fire. Different apps cause difference events to fire.

I'll probably do this in the Watcher events:
private FileWatcher_Changed(...)
{
    while(!IsFileAvailable())
    {
      // Do nothing until file is read-write<br />
    }

    // Do other stuff with the file
}

public bool IsFileAvailable(String sFilename)
{
    bool results = false;

    try
    {
        using (var inputStream = File.Open(sFilename, FileMode.Open, FileAccess.Read, FileShare.None))
        {
            results = inputStream.Length > 0;
        }
    }
    catch (Exception)
    {
        results = false;
    }

    return results;
}

[UPDATE]

Just tried it. Worked fine.
If it's not broken, fix it until it is

GeneralRe: FileSystemWatcher Problem Pin
Gerry Schmitz22-Feb-16 8:09
mveGerry Schmitz22-Feb-16 8:09 
GeneralRe: FileSystemWatcher Problem Pin
Kevin Marois22-Feb-16 8:19
professionalKevin Marois22-Feb-16 8:19 
GeneralRe: FileSystemWatcher Problem Pin
Gerry Schmitz22-Feb-16 8:29
mveGerry Schmitz22-Feb-16 8:29 
GeneralRe: FileSystemWatcher Problem Pin
Kevin Marois22-Feb-16 8:32
professionalKevin Marois22-Feb-16 8:32 
GeneralRe: FileSystemWatcher Problem Pin
Kevin Marois22-Feb-16 10:51
professionalKevin Marois22-Feb-16 10:51 
GeneralRe: FileSystemWatcher Problem Pin
Gerry Schmitz22-Feb-16 12:22
mveGerry Schmitz22-Feb-16 12:22 
QuestionPath.Combine ignoring first parameter of three Pin
Member 1185433519-Feb-16 3:59
Member 1185433519-Feb-16 3:59 
AnswerRe: Path.Combine ignoring first parameter of three Pin
Richard MacCutchan19-Feb-16 4:07
mveRichard MacCutchan19-Feb-16 4:07 
GeneralRe: Path.Combine ignoring first parameter of three Pin
Member 1185433519-Feb-16 4:11
Member 1185433519-Feb-16 4:11 
QuestionC# Pin
Member 1116162517-Feb-16 23:39
Member 1116162517-Feb-16 23:39 
AnswerRe: C# Pin
Richard MacCutchan17-Feb-16 23:53
mveRichard MacCutchan17-Feb-16 23:53 
AnswerRe: C# Pin
Jochen Arndt17-Feb-16 23:56
professionalJochen Arndt17-Feb-16 23:56 
AnswerRe: C# Pin
OriginalGriff17-Feb-16 23:59
mveOriginalGriff17-Feb-16 23:59 
SuggestionRe: C# Pin
Richard Deeming18-Feb-16 2:45
mveRichard Deeming18-Feb-16 2:45 
AnswerRe: C# Pin
BillWoodruff18-Feb-16 8:54
professionalBillWoodruff18-Feb-16 8:54 
GeneralRe: C# Pin
Mycroft Holmes18-Feb-16 13:18
professionalMycroft Holmes18-Feb-16 13:18 
GeneralRe: C# Pin
BillWoodruff18-Feb-16 16:13
professionalBillWoodruff18-Feb-16 16:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.