I've been working on a program designed to allow the end user to offer data corrections back to my company. (That is, they send us the originals, we process those and store it in a database, and this program is supposed to allow them to search the DB and send us back a file with any changes that need to be made.)

The sending back of a file is the part where I'm asking for assistance. At the moment, I can correctly write the file out to the necessary network location. However, I'd like to be able to add an error message if something happens to the file during transmission. At the moment, the only thing I can think of is try to have the program find the filename at the target location, and I'm trying to come up with a way to do that. I've found some stuff about a 'TFileFind' on google, and I'm continuing to follow that up, but I was wondering about what other, possibly simpler, methods exist to simply verify the existence of a file from within a delphi program.

Hopefully that largish paragraph made sense...anyone have any suggestions for alternative paths to my goal?

Thanks.

this is from delphi's help:

the following example uses an edit control, a button, a string grid, and seven check boxes. The check boxes correspond to the seven possible file attributes. When the button is clicked, the path specified in the edit control is searched for files matching the checked file attributes. The names and sizes of the matching files are inserted into the string grid.

procedure TForm1.Button1Click(Sender: TObject);

var
sr: TSearchRec;
FileAttrs: Integer;
begin
StringGrid1.RowCount := 1;
if CheckBox1.Checked then
FileAttrs := faReadOnly
else
FileAttrs := 0;
if CheckBox2.Checked then
FileAttrs := FileAttrs + faHidden;
if CheckBox3.Checked then
FileAttrs := FileAttrs + faSysFile;
if CheckBox4.Checked then
FileAttrs := FileAttrs + faVolumeID;
if CheckBox5.Checked then

FileAttrs := FileAttrs + faDirectory;
if CheckBox6.Checked then
FileAttrs := FileAttrs + faArchive;
if CheckBox7.Checked then

FileAttrs := FileAttrs + faAnyFile;

if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then

begin
with StringGrid1 do
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
Cells[1,RowCount-1] := sr.Name;
Cells[2,RowCount-1] := IntToStr(sr.Size);
end;
while FindNext(sr) = 0 do
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
RowCount := RowCount + 1;
Cells[1, RowCount-1] := sr.Name;

Cells[2, RowCount-1] := IntToStr(sr.Size);
end;
end;
FindClose(sr);
end;
end;
end;

----------------------------------------------
here you have the code and component you're talking about(TfindFile)

http://delphi.about.com/od/vclwriteenhance/a/tfindfile.htm

the part above is only how to locate the file on the remote computer.but you haven't said nothing about how you connect to that computer.

best regards,

commented: Thank you for your assistance. +2

Thank you for your assistance, but I found a sort of kludgy way around the problem. I set a button to attempt to reopen the file, then to catch the error if the file doesn't exist and spit out a warning of my own if that happens, instead of the normal exception error. The 'Write file' button ends with a call to the test button.

As to linking into the remote location, I swiped some code from a program my predecessor wrote that does the job; it's simply opening up a specific Samba share on the remote (Linux) box. I'm still figuring out how it works, but I've got enough of it to do everything I needed for that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.