473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Keep checking existing file?

Hi everyone,

I have a question would like to ask. So far I know how to retrieve files from device, but sometimes device takes so long to produce file so I want my desktop to keep checking every 3seconds to see if file exist. Here is the conditions.

1- if file exists after checking for exisitng is True, then desktop application will continue to do other stuff.
2- if file doesn't exist after three times of checking, then desktop sends messagebox unable to retrieve file.

can someone help me on that? I'm stuck on how can I keep checking every 3 seconds, but not more than 3 times.

thanks in advance.
Aug 20 '08 #1
4 2655
LTCCTL
49
Hi,

please provide information about the language and platform.

Regards
LTCCTL
Aug 20 '08 #2
opp sorry. I'm using C# under windowsXP and device is WM 5/6.

thanks.
Aug 20 '08 #3
opp sorry. I'm using C# under windowsXP and device is WM 5/6.

thanks.
Sorry I sort change my approach now. Now I just want my desktop to wait for number of seconds before executing the next statement, and here is what I got so far, but it seems the Timer Event doesn't get executed property probably becauset he call to waiting() is executed after the copying the device result file if-statement.


Expand|Select|Wrap|Line Numbers
  1.  
  2. System.Timers.Timer time;//global Timer variable;
  3.  
  4.  
  5.     private void StartTask()
  6.     {
  7.  
  8.             //Connect to device and copy test case file onto device.
  9.             using (RAPI rapi = new RAPI())
  10.             {
  11.                 rapi.Connect(true);
  12.                 rapi.CopyFileToDevice(testCaseFile, @"\" + testCaseFile, true);
  13.  
  14.                 if (rapi.DeviceFileExists(@"\" + deviceResultFile))
  15.                     rapi.DeleteDeviceFile(@"\" + deviceResultFile);
  16.  
  17.                 //Run the exe file.
  18.                 if (rapi.DeviceFileExists(@"\" + cameraDeviceExecutableFile))
  19.                     rapi.CreateProcess(@"\" + cameraDeviceExecutableFile);
  20.                 else
  21.                 {
  22.                     showTestImage(errorImage);
  23.                     cameraRichTxtBox.SelectionColor = Color.Red;
  24.                     cameraRichTxtBox.AppendText("\nDevice executable file does not exist.");
  25.                 }
  26.  
  27.                 Waiting();
  28.  
  29.                 if (rapi.DeviceFileExists(@"\" + deviceResultFile))
  30.                 {
  31.                     rapi.CopyFileFromDevice(deviceResultFile, @"\" + deviceResultFile, true);
  32.                     deviceResultFileExist = true;
  33.                 }
  34.                 else
  35.                 {
  36.                     showTestImage(errorImage);
  37.                     cameraRichTxtBox.SelectionColor = Color.Red;
  38.                     cameraRichTxtBox.AppendText("\nDevice Result file does not exist.");
  39.                     deviceResultFileExist = false;
  40.                 }
  41.  
  42.                 rapi.Disconnect();
  43.             }
  44.  
  45.        }
  46.  
  47.  
  48.  
  49.         //Function: Waiting
  50.         //Purpose: 
  51.         private void Waiting()
  52.         {
  53.             time = new System.Timers.Timer();
  54.             time.Elapsed += new ElapsedEventHandler(TimerEvent);
  55.             time.Interval = 1000;//each second will raise an event.
  56.             time.Enabled = true;
  57.         }
  58.  
  59.         private void TimerEvent(object source, ElapsedEventArgs e)
  60.         {
  61.             countWaiting++;
  62.             MessageBox.Show(countWaiting.ToString());
  63.  
  64.             if(countWaiting == 10)
  65.                 time.Enabled = false;
  66.         }
  67.  
Aug 20 '08 #4
Please disregard this post because I misunderstood the Timer.
Aug 20 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
14
by: Leslaw Bieniasz | last post by:
Cracow, 3.01.2005 Hello, When opening a file stream in the append mode, either a new file is created (if a specified file does not exist), or an existing file is opened for adding stuff. Is...
15
by: Geiregat Jonas | last post by:
is using if(open("file",O_EXCL) != -1){ printf("File does exists")}else{printf("file does not exists"); } a good way of checking if a file exists or not, if not how should I do it ?
3
by: sparks | last post by:
I have 2 fields that I have to make sure don't get screwed up. (could be one it doesn't matter) but what they want is no duplicates, warn the user changing existing numbers is a no no. (of course...
1
by: Yehia A.Salam | last post by:
hello, is there a setting in visual studio which enable me to keep the files original locations, for example when I add a new Resource VS automatically copy it the Resources folder and use this...
26
by: Army1987 | last post by:
Is this a good way to check wheter a file already exists? #include <stdio.h> #include <stdlib.h> int ask(const char *prompt); typedef char filename; int main(int argc, char *argv) { FILE...
2
by: Bart | last post by:
Hi, i use the FileUpload control but if the uploaded file already exists, i want let the choice between overwriting or not the existing file. Therefore i use a radiobuttonlist with 'yes' and...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
0
by: whizkid0000 | last post by:
Greetings all. I am working on VSS automation. The following link will give a clearer picture of what I'm doing. http://msdn2.microsoft.com/en-us/library/4d44xhsd(VS.80).aspx ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.