Domanda

I have a c# program which is using FileSystemWatcher to watch and get the lines. But my concern is that I am not getting which assembly reference I need to add to remove red error mark from the program ..

Here is my code..

public void File_Changed(object source, FileSystemEventArgs e)
{
        lock (this)
        {
            if (!this.bPaused)
            {
                bool bMoreData = false;

                // Read from current seek position to end of file
                byte[] bytesRead = new byte[this.iMaxBytes];
                FileStream fs = new FileStream(this.strFilename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

                if (0 == this.iPreviousSeekPos)
                {
                    if (this.bReadFromStart)
                    {
                        if (null != this.BeginReadStart)
                        {
                            this.BeginReadStart(null, null);
                        }
                        this.bReadingFromStart = true;
                    }
                    else
                    {
                        if (fs.Length > this.iMaxBytes)
                        {
                            this.iPreviousSeekPos = fs.Length - this.iMaxBytes;
                        }
                    }
                }

                this.iPreviousSeekPos = (int)fs.Seek(this.iPreviousSeekPos, SeekOrigin.Begin);
                int iNumBytes = fs.Read(bytesRead, 0, this.iMaxBytes);
                this.iPreviousSeekPos += iNumBytes;

                // If we haven't read all the data, then raise another event
                if (this.iPreviousSeekPos < fs.Length)
                {
                    bMoreData = true;
                }

                fs.Close();

                string strData = this.encoding.GetString(bytesRead);
                this.MoreData(this, strData);

                if (bMoreData)
                {
                    File_Changed(null, null);
                }
                else
                {
                    if (this.bReadingFromStart)
                    {
                        this.bReadingFromStart = false;
                        if (null != this.EndReadStart)
                        {
                            this.EndReadStart(null, null);
                        }
                    }
                }
            }
        }
    }

I am getting red underline marks in the following code snippets ..

if (!this.bPaused)
this.iMaxBytes
this.iPreviousSeekPos
this.bReadFromStart

Please guys help me.

Thanks in advance..

È stato utile?

Soluzione

According to your code and the symptoms you describe, it's likely that your class doesn't define the fields bPaused, iMaxBytes, iPreviousSeekPos and bReadFromStart.

In particular, it doesn't seem to be due to a reference issue.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top