473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to get only the first file in a directoy without reading the entire directory file collection first

Hello,

I have the following code below that does not work for me because the
directory has millions of files.

foreach (string ofile in System.IO.Directory.GetFiles(strMyDir))

{

System.IO.FileInfo oFI = new System.IO.FileInfo(ofile);

oFI.Delete();

}

How can I get the first file and delete it then go back and get the first
file and delete it and repeat....

My system crashes because System.IO.Directory.GetFiles(strMyDir)) has to
ready 100 million files first.

Any ideas

thanks

SA


Mar 2 '06 #1
2 1842
Delete all files from the command line. You don't create/delete 100 millions
of files in a real world application do you?
Willy.

"MSDN" <sq**********@hotmail.com> wrote in message
news:un**************@tk2msftngp13.phx.gbl...
| Hello,
|
| I have the following code below that does not work for me because the
| directory has millions of files.
|
| foreach (string ofile in System.IO.Directory.GetFiles(strMyDir))
|
| {
|
| System.IO.FileInfo oFI = new System.IO.FileInfo(ofile);
|
| oFI.Delete();
|
| }
|
| How can I get the first file and delete it then go back and get the first
| file and delete it and repeat....
|
| My system crashes because System.IO.Directory.GetFiles(strMyDir)) has to
| ready 100 million files first.
|
| Any ideas
|
| thanks
|
|
|
| SA
|
|
|
|
Mar 2 '06 #2
Done with it in C++
Yes Machines creating files..

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Delete all files from the command line. You don't create/delete 100
millions
of files in a real world application do you?
Willy.

"MSDN" <sq**********@hotmail.com> wrote in message
news:un**************@tk2msftngp13.phx.gbl...
| Hello,
|
| I have the following code below that does not work for me because the
| directory has millions of files.
|
| foreach (string ofile in System.IO.Directory.GetFiles(strMyDir))
|
| {
|
| System.IO.FileInfo oFI = new System.IO.FileInfo(ofile);
|
| oFI.Delete();
|
| }
|
| How can I get the first file and delete it then go back and get the
first
| file and delete it and repeat....
|
| My system crashes because System.IO.Directory.GetFiles(strMyDir)) has to
| ready 100 million files first.
|
| Any ideas
|
| thanks
|
|
|
| SA
|
|
|
|

Apr 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Xerxes | last post by:
Hi, I have a link in my page that allows users to download an exe file. However, when I download and run it, it briefly displays the DOS box and nothing happens. In my php file, I have: ...
9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
6
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
5
by: matt dittman | last post by:
I have created a windows service that reads emails from a drop directory and moves them to the appropriate mail folder every 15 seconds. I can move, rename and delete the files as needed, up...
7
by: Brian Sabolik | last post by:
I'm not sure if I've broken any Object Oriented rules or not, but ... I have projects in 2 different solutions that need to use each other's methods. Therefore I may have an "update" method in...
23
by: da Vinci | last post by:
Greetings, Onwards with the school studying. Working on a program and need to delete a file from a known location on the hard drive but cannot get anything I do to work. I have tried to use...
2
by: David | last post by:
I'm using following code for checking a file existence. I's working fine for given folder. Is there a way to check a file exitance in subfolders? Thanks in advance, David Option Compare...
4
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
1
by: rachana | last post by:
Hello, I have got one asp.net application which works fine on my local machine. When moved on the server, I get error, Server Error in '/MyApplication' Application....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.