473,586 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving files from folder in the order they are send

Hi,
I am in a problem.
I am sending files to a particular folder one after the another.
Than obviosly there create time is different.
Now suppose if there are 50 files and i want to retrive the files in the
order they are sent i.e. file with first create time(First in First Out).
Is it possible.
I couldn't find any such property of sorting.
Please send any link or line of code.

Answer will be appreciated

Thanking U,
Carol
Dec 16 '05 #1
5 1750
Carol,

Suppose you have an array of FileInfo instances which you need sorted,
you could do this:

// The file info array, assume it is populated.
FileInfo[] fileInfo;

Array.Sort(file Info,
delegate(FileIn fo x, FileInfo y)
{
// If the create time on x is greater than y, then return 1, if it
is equal, then return 0, otherwise, return -1.
if (x.CreationTime Utc == y.CreationTimeU tc)
{
// Return 0.
return 0;
}
else
{
// Check to see if x > y.
if (x.CreationTime Utc > y.CreationTimeU tc)
{
// Return 1.
return 1;
}
else
{
// y > x.
return -1;
}
}
});

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Carol" <Ca***@discussi ons.microsoft.c om> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
Hi,
I am in a problem.
I am sending files to a particular folder one after the another.
Than obviosly there create time is different.
Now suppose if there are 50 files and i want to retrive the files in the
order they are sent i.e. file with first create time(First in First Out).
Is it possible.
I couldn't find any such property of sorting.
Please send any link or line of code.

Answer will be appreciated

Thanking U,
Carol

Dec 16 '05 #2
I don't think there is a way to actually retrieve the list of files in a
sorted order.
I would say just get the list in whatever order it gives them to you, then
loop through each one and create a new SortedList, where the key is the
creation date (or modified, whatever you need), and the value is the
filename/path.

--
Adam Clauss

"Carol" <Ca***@discussi ons.microsoft.c om> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
Hi,
I am in a problem.
I am sending files to a particular folder one after the another.
Than obviosly there create time is different.
Now suppose if there are 50 files and i want to retrive the files in the
order they are sent i.e. file with first create time(First in First Out).
Is it possible.
I couldn't find any such property of sorting.
Please send any link or line of code.

Answer will be appreciated

Thanking U,
Carol

Dec 16 '05 #3
Hi Nicholos,
Thanks for your reply
Can u plaease clarify your code.
I have copy pated buts its not working.
Can u please resend it.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Carol,

Suppose you have an array of FileInfo instances which you need sorted,
you could do this:

// The file info array, assume it is populated.
FileInfo[] fileInfo;

Array.Sort(file Info,
delegate(FileIn fo x, FileInfo y)
{
// If the create time on x is greater than y, then return 1, if it
is equal, then return 0, otherwise, return -1.
if (x.CreationTime Utc == y.CreationTimeU tc)
{
// Return 0.
return 0;
}
else
{
// Check to see if x > y.
if (x.CreationTime Utc > y.CreationTimeU tc)
{
// Return 1.
return 1;
}
else
{
// y > x.
return -1;
}
}
});

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Carol" <Ca***@discussi ons.microsoft.c om> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
Hi,
I am in a problem.
I am sending files to a particular folder one after the another.
Than obviosly there create time is different.
Now suppose if there are 50 files and i want to retrive the files in the
order they are sent i.e. file with first create time(First in First Out).
Is it possible.
I couldn't find any such property of sorting.
Please send any link or line of code.

Answer will be appreciated

Thanking U,
Carol


Dec 16 '05 #4
Carol,

Are you using .NET 1.1 or 2.0? The code is written for C# 2.0.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Carol" <Ca***@discussi ons.microsoft.c om> wrote in message
news:49******** *************** ***********@mic rosoft.com...
Hi Nicholos,
Thanks for your reply
Can u plaease clarify your code.
I have copy pated buts its not working.
Can u please resend it.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Carol,

Suppose you have an array of FileInfo instances which you need
sorted,
you could do this:

// The file info array, assume it is populated.
FileInfo[] fileInfo;

Array.Sort(file Info,
delegate(FileIn fo x, FileInfo y)
{
// If the create time on x is greater than y, then return 1, if
it
is equal, then return 0, otherwise, return -1.
if (x.CreationTime Utc == y.CreationTimeU tc)
{
// Return 0.
return 0;
}
else
{
// Check to see if x > y.
if (x.CreationTime Utc > y.CreationTimeU tc)
{
// Return 1.
return 1;
}
else
{
// y > x.
return -1;
}
}
});

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Carol" <Ca***@discussi ons.microsoft.c om> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
> Hi,
> I am in a problem.
> I am sending files to a particular folder one after the another.
> Than obviosly there create time is different.
> Now suppose if there are 50 files and i want to retrive the files in
> the
> order they are sent i.e. file with first create time(First in First
> Out).
> Is it possible.
> I couldn't find any such property of sorting.
> Please send any link or line of code.
>
> Answer will be appreciated
>
> Thanking U,
> Carol


Dec 16 '05 #5
"Nicholas Paldino [.NET/C# MVP]" wrote:
Carol,

Suppose you have an array of FileInfo instances which you need sorted,
you could do this:

// The file info array, assume it is populated.
FileInfo[] fileInfo;

Array.Sort(file Info,
delegate(FileIn fo x, FileInfo y)
{
// If the create time on x is greater than y, then return 1, if it
is equal, then return 0, otherwise, return -1.
if (x.CreationTime Utc == y.CreationTimeU tc)
{
// Return 0.
return 0;
}
else
{
// Check to see if x > y.
if (x.CreationTime Utc > y.CreationTimeU tc)
{
// Return 1.
return 1;
}
else
{
// y > x.
return -1;
}
}
});

or simply x.CreationTimeU tc.CompareTo( y.CreationTimeU tc )
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Carol" <Ca***@discussi ons.microsoft.c om> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
Hi,
I am in a problem.
I am sending files to a particular folder one after the another.
Than obviosly there create time is different.
Now suppose if there are 50 files and i want to retrive the files in the
order they are sent i.e. file with first create time(First in First Out).
Is it possible.
I couldn't find any such property of sorting.
Please send any link or line of code.

Answer will be appreciated

Thanking U,
Carol


Dec 16 '05 #6

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

Similar topics

6
9642
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been made for service staff. My problem is the SQL is not retrieving the value of the listbox. I have tested the SQL by entering a fixed value of a...
3
2236
by: Brian Farnhill (MCP VB.NET) | last post by:
Hi, I am having some trouble using the MailMessage object to send an email with more than one attachment. I am working on a web based application where a user can submit information, along with a number of files. The information, including the file is stored in the database, and an email is sent with the information and any files that...
4
1367
by: Yves | last post by:
Hello, I have a little question. I want to make a small app that counts all the files located in a specific directory (chosen via a FolderBrowserDialog by a user). The question is: is there a method (of something else) that can retrieve all the files (in that specific directory) and subdirectories (and in possible subdirectories of the...
4
3273
by: johnb41 | last post by:
In my application, the user opens up a Tiff image. (The file does NOT necessarily have to be the first file in the folder; it could by anywhere.) When i'm done viewing (doing whatever) with the image I need to open up the "Next" Tiff file in the folder. This should be done by clicking a button instead of using the FileOpen dialog again and...
7
2004
by: jonathandrott | last post by:
sorry newbie question probably. i'm trying to open an specific folder. open each file with in the folder individually and process each one. all the processing code has been written. i'm looking for sample code to open the folder and start grabbing files. thanks.
4
24318
by: Joey | last post by:
asp.net 2/C#/VS2005 I have a web app where I use a stream writer to create a CSV (text) file. I then use my code to save the file in the site's 'App_Data' folder, in a subfolder called 'Temp'. Finally, I redirect the page to that file in order to serve it out (push the download) to the user. This all worked great in .net v1.1. Now, in my...
21
34375
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready...
18
34719
jhardman
by: jhardman | last post by:
Have you ever wanted to upload files through a form and thought, "I'd really like to use ASP, it surely has that capability, but the tutorial I used to learn ASP didn't mention how to do this."? Have you looked around trying to find simple solutions but didn't want to wade through pages of complex code? Have you balked at paying for premade...
3
5173
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
7912
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.