Article View: borland.public.cppbuilder.nativeapi
Article #10071Re: Temporary File
From: Randel Bjorkquist
Date: Wed, 26 May 2004 17:52
Date: Wed, 26 May 2004 17:52
91 lines
3740 bytes
3740 bytes
Hey Remy,
I can not change the file extention. I am using this in a view file
procedure, I've copied it below. I am retrieving the file and letting
windows open it with its associated program. So if I change it, I'm not
sure how to open the file so the end-user can see it. I guess I was being
lazy by trying to let Windows clean it up without having to write something
to do it. It didn't look like that was going to happen, so I've ended up
writing a TmpFileCleanUp procedure. But, if you have any other ideas, I'll
be more then happy to look at them.
Thanks for the help,
Randel Bjorkquist
//--------------------------------------------------------------------------
-
void __fastcall TAuditAttachment::ViewAttachment(void)
{
char TPath[256];
AnsiString TmpPath;
AnsiString TmpFileName;
AnsiString FilterString;
TTable* TmpTable = new TTable(Application);
TmpTable->DatabaseName = DatabaseName;
TmpTable->TableName = AD_TABLE_NAME;
FilterString = "(AuditID = '" + (AnsiString)FAuditID + "') ";
FilterString += "AND ";
FilterString += "([FileName] = '" + FFileName + "')";
TmpTable->Filter = FilterString;
TmpTable->Filtered = true;
TmpTable->ReadOnly = true;
TmpTable->Active = true;
TFileStream* FileStream;
TBlobStream* BlobStream;
BlobStream =
dynamic_cast<TBlobStream*>(TmpTable->CreateBlobStream(TmpTable->FieldByName(
"FileData"), bmRead));
GetTempPath(sizeof(TPath), TPath);
TmpPath = TPath;
TmpFileName = TmpPath;
TmpFileName += "catmp_";
TmpFileName += FileName;
try{
FileStream = new TFileStream(TmpFileName, fmCreate);
if(BlobStream != NULL){
FileStream->CopyFrom(BlobStream, 0);
}//end of "if(BlobStream != NULL)"
}//end of "try-block"
__finally{
delete FileStream;
delete BlobStream;
TmpTable->Active = false;
delete TmpTable;
}//end of "__finally"
if((int)ShellExecute(NULL, "open", TmpFileName.c_str(),
NULL, NULL, SW_SHOW) == SE_ERR_NOASSOC){
WinExec(("rundll32.exe shell32.dll, OpenAs_RunDLL " +
TmpFileName).c_str(), SW_NORMAL);
}//end of "if-statement"
}//end of "TAuditAttachment::ViewAttachment()" method
"Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message
news:40b2276a$1@newsgroups.borland.com...
>
> "Randel Bjorkquist" <rbjorkquist@coilcraft.com> wrote in message
> news:40b21cf1$1@newsgroups.borland.com...
>
> > I just tried what you were sugguesting, but it didn't work.
> > The "Disk Cleanup.exe", skipped right over my file.
>
> Try giving the file the ".tmp" extension.
>
>
> Gambit
>
>
Technical Details
Message-ID:
<40b4d96f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<40b2105a$1@newsgroups.borland.com> <40b21210@newsgroups.borland.com> <40b216d1@newsgroups.borland.com> <40b21989$1@newsgroups.borland.com> <40b21cf1$1@newsgroups.borland.com> <40b2276a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,30cb4b5f364f10fa X-Google-Attributes: gid10cc67,public From: "Randel Bjorkquist" <rbjorkquist@coilcraft.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40b2105a$1@newsgroups.borland.com> <40b21210@newsgroups.borland.com> <40b216d1@newsgroups.borland.com> <40b21989$1@newsgroups.borland.com> <40b21cf1$1@newsgroups.borland.com> <40b2276a$1@newsgroups.borland.com> Subject: Re: Temporary File Date: Wed, 26 May 2004 12:52:43 -0500 Lines: 93 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 209.172.185.194 Message-ID: <40b4d96f@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1085593967 209.172.185.194 (26 May 2004 10:52:47 -0700) Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail