Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2005

Tip: Looking for answers? Try searching our database.

Temporary Flat Files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thom Little - 07 Mar 2005 17:06 GMT
I have an ASP 3 application that I am converting to and improving with
ASP.NET.  This application creates two temporary flat files and appends them
to an SMTP mail message that it then sends.

Can I use the Cache in ASP.NET for a similar purpose instead of writing to
and reading from disk on the server?  Is there a better approach?

Is there an example or description that you can recommend?

Signature

--  Thom Little  --  www.tlanet.net  --  Thom Little Associates, Ltd.
--

Manohar Kamath - 07 Mar 2005 17:17 GMT
The following article contains code to create attachments, you could perhaps
modify it to use a stream instead.

http://www.eggheadcafe.com/articles/20030316.asp

I am guessing there is code somewhere that writes these flat files. So,
instead of writing the files, pass the stream to the above code. Hope that
helps.

Signature

Manohar Kamath
Editor, .netWire
www.dotnetwire.com

> I have an ASP 3 application that I am converting to and improving with
> ASP.NET.  This application creates two temporary flat files and appends them
[quoted text clipped - 4 lines]
>
> Is there an example or description that you can recommend?
Thom Little - 07 Mar 2005 20:28 GMT
That is a very interesting article and probably helpful for solving a larger
problem that I have.

I currently have the revised application written and tested to use Smtp.  It
is invoked with a form from any HTTP page.  The remaining issue is to create
and attach two files.  I am looking for an example that allows me to attach
"files" that are not physically resident on disk.  Perhaps this is a
capability provided by the Cache?

The reason is that writing them to disk makes it necessary to have a
dedicated folder (temp) that has permissions adjusted for ASP.NET access.
This makes it cumbersome to setup when moved to a server under some else's
control.

Signature

--  Thom Little  --  www.tlanet.net  --  Thom Little Associates, Ltd.
--

> The following article contains code to create attachments, you could
> perhaps
[quoted text clipped - 5 lines]
> instead of writing the files, pass the stream to the above code. Hope that
> helps.
[MSFT] - 08 Mar 2005 02:19 GMT
Hello Thom,

The object in ASP.NET cache cannot be used as actual file for amail
attachment. I think Manohar's suggestion is the right way to resolve the
problem. You can take a look at following code in the sample he recommended:

MailAttachment a = o as MailAttachment;
byte[] binaryData;
if(a!=null)
{
FileInfo f = new FileInfo(a.Filename);
sb.Append("--unique-boundary-1\r\n");
sb.Append("Content-Type: application/octet-stream; file=" + f.Name +
"\r\n");
sb.Append("Content-Transfer-Encoding: base64\r\n");
sb.Append("Content-Disposition: attachment; filename=" + f.Name + "\r\n");
sb.Append("\r\n");
FileStream fs = f.OpenRead();
binaryData = new Byte[fs.Length];
long bytesRead = fs.Read(binaryData, 0, (int)fs.Length);
fs.Close();
string base64String = System.Convert.ToBase64String(binaryData,
0,binaryData.Length);

..

Above code add an attachment to the mail and data is in the byte array.
Based on the sample, you can load your data in a byte array or stream, and
then add to the mail.

Luke

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.