Hi, -
Public Sub FindInternetCache()
-
Dim cacheDir As String = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)
-
-
Dim cacheFiles As ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles(cacheDir, FileIO.SearchOption.SearchAllSubDirectories, "*.*")
-
-
-
Dim fCounter As Integer = 0
-
Dim fSize As Double
-
-
-
For Each cacheFound As String In cacheFiles
-
fCounter = fCounter + 1
-
-
-
DisplayBox.Text &= Environment.NewLine
-
DisplayBox.Text &= "Found: " & cacheFound & Environment.NewLine
-
-
-
fSize += My.Computer.FileSystem.GetFileInfo(cacheFound).Length
-
Next
-
-
-
DisplayBox.Text &= Environment.NewLine
-
DisplayBox.Text &= "IE Temporary Internet Files Found " & "(" & fCounter & " Files) " & SetBytes(fSize) & Environment.NewLine
-
-
-
End Sub
-
I am using the above function to Output all the files in the Temporary Internet Files folder - its working alright. But its very slow and also hangs.
I was wondering if theres a better method to do this.
Thank you
Regards
13 1761 Plater 7,872
Recognized Expert Expert
Is it faster if you use the the .NET Directory.GetFiles() function and not that strange Computer.FileSystem call?
Is it faster if you use the the .NET Directory.GetFiles() function and not that strange Computer.FileSystem call?
it seems to be the same
i used it like this to find all files - Directory.GetFiles(cacheDir, "*.*", SearchOption.AllDirectories)
:(
Try using the DirectoryInfo object. See if that is any faster.
Try using the DirectoryInfo object. See if that is any faster.
Oops, sorry i forgot about this :(
I tried the directoryInfo object with no help.
:(
Plater 7,872
Recognized Expert Expert
Well the temporary internet cache is usually PACKED with files... I have over 3k in mine right now.
It takes IE quiet a long time to flush the cache as well.
Also, why are you doing this??
fCounter = fCounter + 1
Why not just say fCounter=cacheFiles.Length after the loop (or before it, it does not matter
Well the temporary internet cache is usually PACKED with files... I have over 3k in mine right now.
It takes IE quiet a long time to flush the cache as well.
Also, why are you doing this??
fCounter = fCounter + 1
Why not just say fCounter=cacheFiles.Length after the loop (or before it, it does not matter
Hi,
it has alot of files but i've seen many apps made in VB and C# that shows all the cache files to the end user but works perfectly fine :(
yeah, i learned that very late about using .length =P
but i still use fCounter to determine how many files were deleted.
i also removed that thinking maybe it could be slowing down :( but that didn't help either :(
:(
Plater 7,872
Recognized Expert Expert
Well I just implented it and I can tell you that its the string concatination that is killing you. I re-wrote it to use a StringBuilder object instead of just concatinating text to the texbox.
Here is the last line (I am not pasting in the Found: lines since there is alot):
IE Temporary Internet Files Found (10492 Files) 203080648
It took .8 seconds. Now granted that time was recorded after the whole thing had been searched durring testing, so it was all indexed for faster searching, but it wasn't too much longer.
So consider making your function return a string value (from a stringbuilder) rather then working directly with a textbox.
Well I just implented it and I can tell you that its the string concatination that is killing you. I re-wrote it to use a StringBuilder object instead of just concatinating text to the texbox.
Here is the last line (I am not pasting in the Found: lines since there is alot):
IE Temporary Internet Files Found (10492 Files) 203080648
It took .8 seconds. Now granted that time was recorded after the whole thing had been searched durring testing, so it was all indexed for faster searching, but it wasn't too much longer.
So consider making your function return a string value (from a stringbuilder) rather then working directly with a textbox.
Hi,
WoW - i was having a doubt that it might be something with the way of outputing the results but i'm still not sure how you did it :(
Is it possible for you to paste the code please =(
Would really appreciate that
Regards
Plater 7,872
Recognized Expert Expert
Well you are aware that string concatination is a degrading effect right? (I only recenlty learned just how BAD it gets)
Everytime you do a &= (or += in c#), it recreates the entire string. So as your string gets longer, it takes more and more time. With a StringBuilder, it does not re-create the string, it does what you would think the &= does, just append things to the end of the string.
I wrote my code in C#, but you could probably see what the changes where: -
private string FindInternetCache()
-
{
-
DateTime Start = DateTime.Now;//Only used for timing
-
StringBuilder retval = new StringBuilder("");
-
int fCounter = 0;
-
double fSize = 0.0;
-
string cacheDir = "";
-
-
cacheDir= Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
-
DirectoryInfo di = new DirectoryInfo(cacheDir);
-
FileInfo[] cacheFiles=di.GetFiles("*.*", SearchOption.AllDirectories);
-
-
foreach (FileInfo cacheFound in cacheFiles)
-
{
-
fCounter = fCounter + 1;
-
fSize += cacheFound.Length;
-
retval.AppendFormat("Found: {0}\r\n", cacheFound.FullName);
-
}
-
retval.AppendFormat("\r\nIE Temporary Internet Files Found ({0} Files) {1}\r\n", fCounter, fSize);
-
DateTime End = DateTime.Now;//Only used for timing
-
TimeSpan t = (End - Start);//Only used for timing
-
-
return retval.ToString();
-
}
-
Awesome,
Thanks for the code Platter :) looks great
and also thanks alot for letting me know about &= never knew it could be that bad :(
I tried using this method - the StringBuilder method but it isn't working :(
i get declare errors when trying to use StringBuilder command - StringBuilder retval = new StringBuilder("");
is the stringbuilder on for C#
how can i use this on VB.net (vb2005)
Thanks in advance
The StringBuilder is in the System.Text namespace.
So, you could use
or you can declare it as - Dim retval As New System.Text.StringBuilder("")
The StringBuilder is in the System.Text namespace.
So, you could use
or you can declare it as - Dim retval As New System.Text.StringBuilder("")
Too Good =D
Thanks it worked that way :)
THANK YOU PLATTER :)
it worked :)
The method you showed worked :)
its working pretty fast now :)
Thanks for the marvelous help :) you're the best ;)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: gulu man |
last post by:
Hi,
What is the substitute for COM objects in .NET?
How can I create something similar to com in .net?
Is it still possible?
Thank you
|
by: Olav.NET |
last post by:
I am a .NET/C++ developer who is supposed to do some work with Access.
I do not know much about it except for the DB part.
Questions:
*1*
I am looking for INTENSIVE books to get quickly up to...
|
by: TAM |
last post by:
Hi,
I read that ASP.NET uses VB.NET instead of VBScript. I also read that
ASP.NET is a subset of VB.NET. So if I learn VB.NET first then do I have the
knowledge for programming ASP.NET...
|
by: Bob |
last post by:
Is ASP.NET 1.1 available on the 64 bit extended version of Windows 2003
Server? When I install VS.NET 2003 I then get Service Unavailable from IIS
when navigating to the main under construction...
|
by: Kevin Spencer |
last post by:
About 2 years ago, and as recently as perhaps 1 year ago, I can recall
seeing many posts about what language to use with ASP.Net. The consensus was
that employers paid more for C# programmers, and...
| |
by: Nathan Sokalski |
last post by:
I have Visual Studio .NET and SQL Server Desktop Engine on my computer. I
have created an empty database using Visual Studio .NET's Server Explorer.
However, I am having trouble connecting to the...
|
by: Juan T. Llibre |
last post by:
Welcome to the ASP.NET FAQ.
Thank you for reading this FAQ!
Use it to improve your online experience.
The Microsoft Public Newsgroups allow users of Microsoft products to exchange technical ...
|
by: Juan T. Llibre |
last post by:
Welcome to the ASP.NET FAQ.
The online version of this FAQ is at http://asp.net.do/faq/
Thank you for reading this FAQ!
Use it to improve your online experience.
The Microsoft Public...
|
by: Kenneth Windish |
last post by:
Hi,
I wrote a simple web application using web matrix. When I run it on my local
computer all works fine, but when I run it on hosting site all hyperlinks
are not working and just postback to...
|
by: Steve H. |
last post by:
Hi all,
I'm searching for a few good books on asp.net and c#. I'm afraid of buying
books here in denmark that i cant read though before i get them, becuase 90%
of them are just pure junk. I...
|
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: 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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
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...
| |