PC Review


Reply
Thread Tools Rate Thread

Delete from file

 
 
Ole
Guest
Posts: n/a
 
      9th Nov 2007
I know that it generally isn't possible to delete a part of a file, but I'll
pop this question anyway in case there is a good idea out there:

I have a program that runs on a PDA with e.g. 32MB storage. The program
generate a file and if the file exceed 16MB I do not have the possibility to
delete a single character from the file, because I normally will have to
create a new file without the character and after that delete the original
file ---- or what????

Thanks
Ole


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2ltb24gSGFydCBbTVZQXQ==?=
Guest
Posts: n/a
 
      9th Nov 2007
I don't understand what you are trying to achieve. Are you saying, when the
file equals a certain size, you want to delete it?
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


"Ole" wrote:

> I know that it generally isn't possible to delete a part of a file, but I'll
> pop this question anyway in case there is a good idea out there:
>
> I have a program that runs on a PDA with e.g. 32MB storage. The program
> generate a file and if the file exceed 16MB I do not have the possibility to
> delete a single character from the file, because I normally will have to
> create a new file without the character and after that delete the original
> file ---- or what????
>
> Thanks
> Ole
>
>
>

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      9th Nov 2007
Sounds like he wants to remove a section of a file that is half the size of
the available storage. Since you can't just cut out some bytes from the
middle, the only practical way to do it is to create a new file and copy
just the parts of the old file that you want into the new file. However, if
the old file is half the size of the storage, that's a problem. There's no
fix that I can think of other than to stop growing the other file sooner...

Paul T.

"Simon Hart [MVP]" <(E-Mail Removed)> wrote in message
news:65CF40AF-3995-4E8A-AFB9-(E-Mail Removed)...
>I don't understand what you are trying to achieve. Are you saying, when the
> file equals a certain size, you want to delete it?
> --
> Simon Hart
> Visual Developer - Device Application Development MVP
> http://simonrhart.blogspot.com
>
>
> "Ole" wrote:
>
>> I know that it generally isn't possible to delete a part of a file, but
>> I'll
>> pop this question anyway in case there is a good idea out there:
>>
>> I have a program that runs on a PDA with e.g. 32MB storage. The program
>> generate a file and if the file exceed 16MB I do not have the possibility
>> to
>> delete a single character from the file, because I normally will have to
>> create a new file without the character and after that delete the
>> original
>> file ---- or what????
>>
>> Thanks
>> Ole
>>
>>
>>



 
Reply With Quote
 
Guest
Posts: n/a
 
      9th Nov 2007
The only thing I could think of is opening the file multiple times with
share access and doing some form of data "shift" using two file pointers -
essentially copying file data within the target file itself. It could be
slow and terribly thrashy if, for example, you deleted a single byte at the
start of a 16MB file. You'd end up copying the entire 16MB one byte at a
time to shift it.

On the plus side, at least it would work.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:e4r%(E-Mail Removed)...
> Sounds like he wants to remove a section of a file that is half the size
> of the available storage. Since you can't just cut out some bytes from
> the middle, the only practical way to do it is to create a new file and
> copy just the parts of the old file that you want into the new file.
> However, if the old file is half the size of the storage, that's a
> problem. There's no fix that I can think of other than to stop growing
> the other file sooner...
>
> Paul T.
>
> "Simon Hart [MVP]" <(E-Mail Removed)> wrote in message
> news:65CF40AF-3995-4E8A-AFB9-(E-Mail Removed)...
>>I don't understand what you are trying to achieve. Are you saying, when
>>the
>> file equals a certain size, you want to delete it?
>> --
>> Simon Hart
>> Visual Developer - Device Application Development MVP
>> http://simonrhart.blogspot.com
>>
>>
>> "Ole" wrote:
>>
>>> I know that it generally isn't possible to delete a part of a file, but
>>> I'll
>>> pop this question anyway in case there is a good idea out there:
>>>
>>> I have a program that runs on a PDA with e.g. 32MB storage. The program
>>> generate a file and if the file exceed 16MB I do not have the
>>> possibility to
>>> delete a single character from the file, because I normally will have to
>>> create a new file without the character and after that delete the
>>> original
>>> file ---- or what????
>>>
>>> Thanks
>>> Ole
>>>
>>>
>>>

>
>



 
Reply With Quote
 
Ole
Guest
Posts: n/a
 
      9th Nov 2007
Sounds like a very useful idea and exactly what I was looking for - will try
it out.

Thanks
Ole


"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
news:(E-Mail Removed)...
> The only thing I could think of is opening the file multiple times with
> share access and doing some form of data "shift" using two file pointers -
> essentially copying file data within the target file itself. It could be
> slow and terribly thrashy if, for example, you deleted a single byte at
> the start of a 16MB file. You'd end up copying the entire 16MB one byte
> at a time to shift it.
>
> On the plus side, at least it would work.
>
>
> --
>
> Chris Tacke, eMVP
> Join the Embedded Developer Community
> http://community.opennetcf.com
>
>
>
> "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
> com> wrote in message news:e4r%(E-Mail Removed)...
>> Sounds like he wants to remove a section of a file that is half the size
>> of the available storage. Since you can't just cut out some bytes from
>> the middle, the only practical way to do it is to create a new file and
>> copy just the parts of the old file that you want into the new file.
>> However, if the old file is half the size of the storage, that's a
>> problem. There's no fix that I can think of other than to stop growing
>> the other file sooner...
>>
>> Paul T.
>>
>> "Simon Hart [MVP]" <(E-Mail Removed)> wrote in message
>> news:65CF40AF-3995-4E8A-AFB9-(E-Mail Removed)...
>>>I don't understand what you are trying to achieve. Are you saying, when
>>>the
>>> file equals a certain size, you want to delete it?
>>> --
>>> Simon Hart
>>> Visual Developer - Device Application Development MVP
>>> http://simonrhart.blogspot.com
>>>
>>>
>>> "Ole" wrote:
>>>
>>>> I know that it generally isn't possible to delete a part of a file, but
>>>> I'll
>>>> pop this question anyway in case there is a good idea out there:
>>>>
>>>> I have a program that runs on a PDA with e.g. 32MB storage. The program
>>>> generate a file and if the file exceed 16MB I do not have the
>>>> possibility to
>>>> delete a single character from the file, because I normally will have
>>>> to
>>>> create a new file without the character and after that delete the
>>>> original
>>>> file ---- or what????
>>>>
>>>> Thanks
>>>> Ole
>>>>
>>>>
>>>>

>>
>>

>
>



 
Reply With Quote
 
Ole
Guest
Posts: n/a
 
      10th Nov 2007
I wonder what happens to the "Tale" of the file and how to tell the OS that
the file has decreased in size.? If I have a file of e.g. 10 KB in size and
I want to delete 1 KB from the middle of it, then I according to the below,
should "shift" the upper part of the file downwards until the the last byte
which is the EOF, but what happens to the last 10KB? Are there any code
snippets available?

Thanks,
Ole

"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
news:(E-Mail Removed)...
> The only thing I could think of is opening the file multiple times with
> share access and doing some form of data "shift" using two file pointers -
> essentially copying file data within the target file itself. It could be
> slow and terribly thrashy if, for example, you deleted a single byte at
> the start of a 16MB file. You'd end up copying the entire 16MB one byte
> at a time to shift it.
>
> On the plus side, at least it would work.
>
> Chris Tacke, eMVP
> Join the Embedded Developer Community
> http://community.opennetcf.com



 
Reply With Quote
 
Guest
Posts: n/a
 
      10th Nov 2007
Simply call SetLength on the FileStream to the new length, Flush and Close.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



"Ole" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I wonder what happens to the "Tale" of the file and how to tell the OS that
>the file has decreased in size.? If I have a file of e.g. 10 KB in size and
>I want to delete 1 KB from the middle of it, then I according to the below,
>should "shift" the upper part of the file downwards until the the last byte
>which is the EOF, but what happens to the last 10KB? Are there any code
>snippets available?
>
> Thanks,
> Ole
>
> "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
> news:(E-Mail Removed)...
>> The only thing I could think of is opening the file multiple times with
>> share access and doing some form of data "shift" using two file
>> pointers - essentially copying file data within the target file itself.
>> It could be slow and terribly thrashy if, for example, you deleted a
>> single byte at the start of a 16MB file. You'd end up copying the entire
>> 16MB one byte at a time to shift it.
>>
>> On the plus side, at least it would work.
>>
>> Chris Tacke, eMVP
>> Join the Embedded Developer Community
>> http://community.opennetcf.com

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can i delete an email and skip the delete file as a single step Hugh Microsoft Outlook Discussion 1 8th Apr 2010 02:07 PM
Delete only unread messages in my delete file =?Utf-8?B?U3Vl?= Microsoft Outlook Discussion 3 7th Jul 2005 12:21 PM
Difference between Delete Subfolders and File and Delete =?Utf-8?B?Um9i?= Microsoft Windows 2000 File System 0 29th Jun 2005 04:31 PM
Re: Macro to delete sheets and saves remaining file does not properly delete module gazornenplat Microsoft Excel Programming 0 22nd Jun 2005 02:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Microsoft Excel Programming 7 21st Jun 2005 06:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 AM.