473,378 Members | 1,390 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,378 software developers and data experts.

Check to see if a pc is on before attempting file.copy

I've built a small app to deploy my apps in a small domain, just for
my own use when I make small updates to pass to my end users. My app
uses File.Copy, and works fine except that it takes a long time to
fail if the machine I'm copying to is in standby, turned off or
hibernating etc.

How could I determine if the machine is running *before* I try
File.Copy? A ping method maybe?

Thanks, Bob

Mar 28 '07 #1
5 1429
"RvGrah" <rv****************@sbcglobal.netwrote in message
news:11*********************@y80g2000hsf.googlegro ups.com...
I've built a small app to deploy my apps in a small domain, just for
my own use when I make small updates to pass to my end users. My app
uses File.Copy, and works fine except that it takes a long time to
fail if the machine I'm copying to is in standby, turned off or
hibernating etc.

How could I determine if the machine is running *before* I try
File.Copy? A ping method maybe?
The client should copy the files from the server to itself when they next
run the app.

Michael
Mar 28 '07 #2
On Mar 27, 9:54 pm, "Michael C" <nos...@nospam.comwrote:
"RvGrah" <rvgrahamsevaten...@sbcglobal.netwrote in message

news:11*********************@y80g2000hsf.googlegro ups.com...
I've built a small app to deploy my apps in a small domain, just for
my own use when I make small updates to pass to my end users. My app
uses File.Copy, and works fine except that it takes a long time to
fail if the machine I'm copying to is in standby, turned off or
hibernating etc.
How could I determine if the machine is running *before* I try
File.Copy? A ping method maybe?

The client should copy the files from the server to itself when they next
run the app.

Michael
So you'd write a launcher that would check for a new version before
the main app runs? I haven't heard of doing that. I'm assuming the app
can't replace itself? If you (or anyone else) have a bit more guidance
I'd appreciate it.

Bob

Mar 28 '07 #3
"RvGrah" <rv****************@sbcglobal.netwrote in message
news:11*********************@y66g2000hsf.googlegro ups.com...
So you'd write a launcher that would check for a new version before
the main app runs? I haven't heard of doing that. I'm assuming the app
can't replace itself? If you (or anyone else) have a bit more guidance
I'd appreciate it.
The way I did it was for the app to be initially installed as per a normal
install (keeping things as close to normal is a Good Thing(tm)). Then when
the customer wished to upgrade your app they should install an update on the
server only. Possibly there should be a check at that time to ensure no one
is using the app or have some way to kick them out. Then as your app is run
on each client machine the app itself should do an initial check to see if
it needs updating. If it does then it should download a seperate program
from the server that will perform the update. The main app should then quit
to allow the update program to proceed. The update program can then copy
files over from the server to the client.

The advantage of this is that you have complete freedom in updating the
update program. Otherwise, say, version 11 will need to be working with
version 10's update program or possibly even an older version. The other
option is to just have the update program being the installer. Yet another
option is to use an MSI with active directory but I'm a bit vague on that
method. There's also ClickOnce deployment but I'm not too familiar with that
either.

Michael
Mar 28 '07 #4
There's a new class in 2.0 called System.Net.NetworkInformation that
exposes fast and easy methods to ping a machine by host name. Here's a
little thing I modified from the help files that did just what I
wanted:

private void TryPing(string myHost, string myUser)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions();

// Use the default Ttl value which is 128,
// but change the fragmentation behavior.
options.DontFragment = true;

// Create a buffer of 32 bytes of data to be transmitted.
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 120;
PingReply reply = pingSender.Send(myHost, timeout, buffer,
options);
if (reply.Status == IPStatus.Success)
{
//htHosts is a hashtable of users and their machines names
htHosts.Add(myUser, myHost);
}
else
{
<snip: here I add to a list of unavailable machines>
}

}
On Mar 27, 10:31 pm, "Michael C" <nos...@nospam.comwrote:
"RvGrah" <rvgrahamsevaten...@sbcglobal.netwrote in message

news:11*********************@y66g2000hsf.googlegro ups.com...
So you'd write a launcher that would check for a new version before
the main app runs? I haven't heard of doing that. I'm assuming the app
can't replace itself? If you (or anyone else) have a bit more guidance
I'd appreciate it.

The way I did it was for the app to be initially installed as per a normal
install (keeping things as close to normal is a Good Thing(tm)). Then when
the customer wished to upgrade your app they should install an update on the
server only. Possibly there should be a check at that time to ensure no one
is using the app or have some way to kick them out. Then as your app is run
on each client machine the app itself should do an initial check to see if
it needs updating. If it does then it should download a seperate program
from the server that will perform the update. The main app should then quit
to allow the update program to proceed. The update program can then copy
files over from the server to the client.

The advantage of this is that you have complete freedom in updating the
update program. Otherwise, say, version 11 will need to be working with
version 10's update program or possibly even an older version. The other
option is to just have the update program being the installer. Yet another
option is to use an MSI with active directory but I'm a bit vague on that
method. There's also ClickOnce deployment but I'm not too familiar with that
either.

Michael

Mar 28 '07 #5
"RvGrah" <rv****************@sbcglobal.netwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
There's a new class in 2.0 called System.Net.NetworkInformation that
exposes fast and easy methods to ping a machine by host name. Here's a
little thing I modified from the help files that did just what I
wanted:
I don't think that's going to help because the ping could fail for various
reasons but the filecopy would still work.

Michael
Apr 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: joethis | last post by:
Is there a way to make sure that a file is already in use using asp? For instance, if one person has opened a file and is about to write to it; then is there a way to keep another user from...
3
by: Colin Graham | last post by:
Error when attempting to export Crystal Report as PDF document asp.net. I get the following error. Error in File...
4
by: ED | last post by:
I currently have 2 oracle databases that my access database is going to gather data from. The IT department wants to give me data snaps in the form of a flat file. They will FTP the flat file to...
19
by: wetherbean | last post by:
Hi group..I am writing a playlist management protocol where I have a file that holds all the playlists and a file that holds all the songs....before a playlist is created I need to check to see if...
12
by: Anders Eriksson | last post by:
Hello! I'm trying to create a program that will watch a directory and when a file is created print that file. I have used FileSystemWatcher for watching the directory and I get an created event....
2
by: James Coe | last post by:
ARGH! Any ideas why this might be happening? The code I'm using comes straight from the example in the VB.NET Help System. All I did was tweak the name= stuff to match my application. Server...
2
by: Grey | last post by:
i have used asp.net to transfer a file from one server to another . i use the system.io.file.copy to copy the file. But i want to know that how can assure the file is transfer complete?? Do i need...
9
by: eggie5 | last post by:
How would I check if a string is a number? e.g: 'asdf2' =false '34' =true 'asf' =false '0' =true
4
by: sherifffruitfly | last post by:
Try to do something with it, and look at the exception? Some other way? Thanks!
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.