What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Check whether file exists

Pages: (2): « First « 1 [ 2 ] Last »
Check whether file exists
Author: Message:
ryxdp
Senior Member
****


Posts: 804
Reputation: 16
30 / Male / Flag
Joined: Jun 2006
O.P. RE: Check whether file exists
Not exactly what I wanted... (or maybe it was...? I'm not too flashy with VB)

anyway, I've set the path in Form1.Load, now all I need is to link up the FileSystemWatcher with _exist_ (the label) somehow, and keep it checking whether PP5022.mi4 exists or not.

So how is that to be done?
04-04-2007 10:40 AM
Profile PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
RE: Check whether file exists
I made a little example:

code:
Public Class Form1

    Private File As String = "C:\DataFile.dat"
    Private mywatcher As New IO.FileSystemWatcher 'Create new instance of FileSystemWatcher

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'Check the first time if the File Exists
        If System.IO.File.Exists(File) Then
            mywatcher.Path = File 'Specify Path to File or Directory. Which ever you need
            mywatcher.IncludeSubdirectories = False
            mywatcher.NotifyFilter = IO.NotifyFilters.DirectoryName Or IO.NotifyFilters.FileName Or IO.NotifyFilters.LastWrite Or IO.NotifyFilters.Security

            AddHandler mywatcher.Deleted, AddressOf OnDeleted  'Use intellisense to see what others are open to you

            mywatcher.EnableRaisingEvents = True     'Start the process
        End If
    End Sub


    Private Sub OnDeleted(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs)
        If e.FullPath = File And e.ChangeType = IO.WatcherChangeTypes.Deleted Then
            'FILE HAS BEEN REMOVED!!
        End If
    End Sub

End Class



WDZ implement auto code coloring :'(
[Image: 1-0.png]
             
04-04-2007 11:32 AM
Profile PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: RE: Check whether file exists
quote:
Originally posted by Ryxpia
quote:
Originally posted by vikke
You can start with telling us what programming language you're programming.
quote:
Originally posted by me
More VB 2005 Express dilemmas

The program it needs to be in opens and sends a file, to be exact "PP5022.mi4" to a dynamic drive label, and all the while there is a Label that will either say "Theme not loaded. Please load theme." or "Theme loaded". Is there something you can put in Form1.Load that will just keep on checking?

If you don't get me, here's the diagram as I see it:

Private Sub Form1.Load [all the rest of that args stuff]
If Form1.Active Then
Keep.On.Checking.If.File.Exists(tillKill)
Using My.Computer.FileSystem.FileExists("E:\PP5022.mi4")

Sorry, but there is no programming language called VB 2005 Express. I suppose you mean VB.Net.

The code by Ezra looks really nice. You should try it! ;)

vikke

This post was edited on 04-04-2007 at 12:04 PM by vikke.
4 8 15 16 23 42
04-04-2007 11:39 AM
Profile E-Mail PM Find Quote Report
ryxdp
Senior Member
****


Posts: 804
Reputation: 16
30 / Male / Flag
Joined: Jun 2006
O.P. RE: Check whether file exists
Ezra, will your code work as I want:

-App is executed
-Code starts
-Person enters and sends a file
-Code sees this and changes label to appropriate text
-App is killed

Hope this is a bit clearer.

EDIT: It seems to work. How do I make an event for -Code sees this and changes label to appropriate text ?

This post was edited on 04-05-2007 at 05:54 AM by ryxdp.
04-05-2007 05:40 AM
Profile PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
RE: Check whether file exists
make an event and pop in this code:
code:
objname.Text = "whatever"
' blah blah blah


This post was edited on 04-06-2007 at 05:35 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
04-06-2007 05:34 AM
Profile PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On