Open URL and refresh it continuously from C# app

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RuiT
    New Member
    • Dec 2009
    • 14

    #16
    I know that refreshing continuously a web browser is not a good solution! It works, sure, but I know it's not great.

    That's why I'm trying to come up with a better solution, as I wrote before: A server-side only solution which replaces images and refreshes only when a new image has arrive to the folder. That's what I'm trying to develop now. I'm using FileSystemWatch er to monitor the folder, as the following code snippet shows:

    Code:
    public partial class _Default : System.Web.UI.Page
    {
        string DirectoryPath = "C:\\Users\\Desktop\\PhotoUpload\\Uploads\\";
     
        protected void Page_Load(object sender, EventArgs e)
        {
            FileSystemWatcher watcher = new FileSystemWatcher();
     
            try
            {
                watcher.Path = DirectoryPath;
                watcher.Created += new FileSystemEventHandler(watcher_Created);
                watcher.EnableRaisingEvents = true;
     
                Image image = Image.FromFile(DirectoryPath + "initial.jpg");
                MemoryStream ms = new MemoryStream();
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                byte[] im = ms.ToArray();
     
                Context.Response.ContentType = "Image/JPG";
                Context.Response.BinaryWrite(im);
            }
            catch (Exception ex)
            {
            }
        }
     
        void watcher_Created(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("File Created: Name: " + e.Name);
     
            try
            {
              //How to display new image?  
            }
            catch (Exception ex)
            {
            }
        }
    }
    Can you give me some hints in how to replace the previous image for the new one? How can I make it refresh so the client watches the sequence of images? Here can I get a tutorial, examples or some kind of help?
    I think that what I want to do is pretty simple, the problem is that I've never worked in web development before.

    Please help.

    PS - Hope you understand by now that I'm not a regular student in a hurry to do my homework. And please note that this is not the core of my project, hence I'm not that concerned about developing the optimal solution and to learn everything about web development.

    Comment

    • jeffanthonyfds
      New Member
      • Mar 2010
      • 1

      #17
      Have you tried using Firefox and an Add-on? URL Flipper comes to mind. https://addons.mozilla.org/en-US/fir...d=5&sort=&lup=

      Comment

      Working...