Downloading files without web browsers
Downloading files without web browsers
- Subject: Downloading files without web browsers
- From: "Stuppel, Searle @ San Diego Central" <email@hidden>
- Date: Fri, 17 Aug 2001 14:01:30 -0700
If i wanted to download a file from the web directly to the desktop/home
directory, could i use the following format? or is there a better way to do
it. I do not want to actually laucnh a web browser to do it.
NSSavePanel *sp;
int runResult;
NSString *fileContents ;
sp = [NSSavePanel savePanel];
[sp setTitle:@"Save Your Report"];
runResult = [sp runModalForDirectory:NSHomeDirectory () file:@""];
if (runResult == NSOKButton)
{
fileContents = [NSString stringWithContentsOfURL:[NSURL
URLWithString:@"
http://www.sketchwork.com/blah.sit"]];
[fileContents writeToFile:[sp filename] atomically:YES];
}
Would this work? Or is there a better way (as i imagine there must be.
Maybe some form of
NSData *someData
someData = [NSString withContentsOfURL:[NSURL
URLWithString:@"
http://www.sketchwork.com/blah.sit"]];
[someData writeToFile:[sp filename] atomically:YES];
(obviously i would need to find the exact command for "withContentsOfURL" if
that happens to not be the exactly right one.
Thanks for any info.
Searle
(and i am at work on a windows machine, so i making some guestimates at code
here)