Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:50:48+00:00 2026-06-14T12:50:48+00:00

I am continuously polling a file to see if it is updated i.e. if

  • 0

I am continuously polling a file to see if it is updated i.e. if some cookie is set in the file by the browser. If I am not running the application, the browser sets the value of cookie into it but if I am running the application, my file cannot be written to. Is there some way to read the file so that it can also be written to simultaneously? Following is the code I’m using:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a timer that polls once every 5 seconds
            var timer = new System.Threading.Timer(TimerProc, null, 5000, 5000);
            Console.WriteLine("Polling every 5 seconds.");
            Console.WriteLine("Press Enter when done:");
            Console.ReadLine();
            timer.Dispose();
        }

        static int TickCount = 0;
        static void TimerProc(object state)
        {
            ++TickCount;
            Boolean found = false;
            Console.WriteLine("tick {0}", TickCount);
            string curFile = @"C:\Users\ACP\AppData\Local\ETH Zuerich\xul_seb\Profiles\cookies.sqlite-wal";
            string line;
            Console.WriteLine(File.Exists(curFile) ? "File exists." : "File does not exist.");
            //Console.WriteLine(File.Exists(curFile) ? "File exists." : "File does not exist.");
            StreamReader file = new StreamReader(curFile);
            while ((line = file.ReadLine()) != null)
            {
                if (line.Contains("SEB"))
                {
                    found=true;
                }
            }
            if (found)
            {
                Console.WriteLine("String exists in the file.");
            }
            else
            {
                Console.WriteLine("String does not exist in the file.");
            }
            file.Close();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:50:50+00:00Added an answer on June 14, 2026 at 12:50 pm

    Create a FileStream in read mode without locking it:

    var file = new FileStream(curFile, FileMode.Open, 
                              FileAccess.Read, FileShare.ReadWrite);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got an application which is polling on a folder continuously. Once any file
I have a C# application..I continuously get a null reference exception..I manage to catch
I have created a desktop application which continuously changes the image on a fixed
I have a windows service which runs continuously and creates some threads to do
I'm in dilema whether to use windows service for my application or not, below
In the application I'm building I'm polling for a status update and I have
I have developed a Web application (HTML5/browser based) for a client which requires fairly
I am working on a chatting application and i was using simple ajax polling
I have a continuously generated data (text file) generated by a program on the
I continuously get the following warning when I build my iPhone application: Application failed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.