Temporary Flat Files

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Temporary Flat Files

    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?

    --
    -- Thom Little -- [url]www.tlanet.net[/url] -- Thom Little Associates, Ltd.
    --



    Thom Little Guest

  2. Similar Questions and Discussions

    1. Help! - ASP.NET cannot 'Temporary ASP NET Files'
      Guys, Sorry if this has been covered and for the cross post(ish). I have tried suggestion I have come across (i.e. Adding myself to the...
    2. DB2 and Flat files
      Hi, I'm new in DB2. Can anyone tell me whether there is any command in DB2 to batch update the contents of a flat file into a DB2 table. ...
    3. indexing flat files
      Hi, I have a file (about 3-4 MB ) with about 20000 records in it. I need to create an index on a particular field (integer ) in each record. But...
    4. How to create .deb of flat files?
      Hi All! I've got a handful of regular flat text files that I would like to make into a .deb but I'm not familiar with doing anything that doesn't...
    5. Temporary files
      I was working on a 100+ MB file when comp restarted, have no idea why, lost almost 2 hours work, in temporary files folder there's a 1GB file which i...
  3. #2

    Default Re: Temporary Flat Files

    The following article contains code to create attachments, you could perhaps
    modify it to use a stream instead.

    [url]http://www.eggheadcafe.com/articles/20030316.asp[/url]

    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.

    --
    Manohar Kamath
    Editor, .netWire
    [url]www.dotnetwire.com[/url]


    "Thom Little" <thom@tlanet.net> wrote in message
    news:OYaSRgzIFHA.1860@TK2MSFTNGP15.phx.gbl...
    > 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?
    >
    > --
    > -- Thom Little -- [url]www.tlanet.net[/url] -- Thom Little Associates, Ltd.
    > --
    >
    >
    >

    Manohar Kamath Guest

  4. #3

    Default Re: Temporary Flat Files

    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.

    --
    -- Thom Little -- [url]www.tlanet.net[/url] -- Thom Little Associates, Ltd.
    --

    "Manohar Kamath" <mkamath@TAKETHISOUTkamath.com> wrote in message
    news:%232IY1lzIFHA.2844@TK2MSFTNGP10.phx.gbl...
    > The following article contains code to create attachments, you could
    > perhaps
    > modify it to use a stream instead.
    >
    > [url]http://www.eggheadcafe.com/articles/20030316.asp[/url]
    >
    > 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.
    >
    > --
    > Manohar Kamath
    > Editor, .netWire
    > [url]www.dotnetwire.com[/url]

    Thom Little Guest

  5. #4

    Default Re: Temporary Flat Files

    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


    [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139