473,566 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[VB.net-WinAPP] - Slow Internet Cache

79 New Member
Hi,

Expand|Select|Wrap|Line Numbers
  1.     Public Sub FindInternetCache()
  2.         Dim cacheDir As String = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)
  3.  
  4.         Dim cacheFiles As ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles(cacheDir, FileIO.SearchOption.SearchAllSubDirectories, "*.*")
  5.  
  6.  
  7.         Dim fCounter As Integer = 0
  8.         Dim fSize As Double
  9.  
  10.  
  11.         For Each cacheFound As String In cacheFiles
  12.             fCounter = fCounter + 1
  13.  
  14.  
  15.         DisplayBox.Text &= Environment.NewLine
  16.         DisplayBox.Text &= "Found: " & cacheFound & Environment.NewLine
  17.  
  18.  
  19.             fSize += My.Computer.FileSystem.GetFileInfo(cacheFound).Length
  20.         Next
  21.  
  22.  
  23.         DisplayBox.Text &= Environment.NewLine
  24.         DisplayBox.Text &= "IE Temporary Internet Files Found " & "(" & fCounter & " Files) " & SetBytes(fSize) & Environment.NewLine
  25.  
  26.  
  27.     End Sub
  28.  
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
Sep 26 '08 #1
13 1770
Plater
7,872 Recognized Expert Expert
Is it faster if you use the the .NET Directory.GetFi les() function and not that strange Computer.FileSy stem call?
Sep 26 '08 #2
zubair1
79 New Member
Is it faster if you use the the .NET Directory.GetFi les() function and not that strange Computer.FileSy stem call?
it seems to be the same

i used it like this to find all files

Expand|Select|Wrap|Line Numbers
  1. Directory.GetFiles(cacheDir, "*.*", SearchOption.AllDirectories)
:(
Sep 26 '08 #3
Curtis Rutland
3,256 Recognized Expert Specialist
Try using the DirectoryInfo object. See if that is any faster.
Sep 26 '08 #4
zubair1
79 New Member
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.

:(
Sep 28 '08 #5
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=cacheF iles.Length after the loop (or before it, it does not matter
Sep 29 '08 #6
zubair1
79 New Member
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=cacheF iles.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 :(

:(
Sep 29 '08 #7
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.
Sep 29 '08 #8
zubair1
79 New Member
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
Sep 29 '08 #9
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:
Expand|Select|Wrap|Line Numbers
  1. private string FindInternetCache()
  2. {
  3.     DateTime Start = DateTime.Now;//Only used for timing
  4.     StringBuilder retval = new StringBuilder("");
  5.     int fCounter = 0;
  6.     double fSize = 0.0;
  7.     string cacheDir = "";
  8.  
  9.     cacheDir= Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
  10.     DirectoryInfo di = new DirectoryInfo(cacheDir);
  11.     FileInfo[] cacheFiles=di.GetFiles("*.*", SearchOption.AllDirectories);
  12.  
  13.     foreach (FileInfo cacheFound in cacheFiles)
  14.     {
  15.         fCounter = fCounter + 1;
  16.         fSize += cacheFound.Length;
  17.         retval.AppendFormat("Found: {0}\r\n", cacheFound.FullName);
  18.     }
  19.     retval.AppendFormat("\r\nIE Temporary Internet Files Found ({0} Files) {1}\r\n", fCounter, fSize);
  20.     DateTime End = DateTime.Now;//Only used for timing
  21.     TimeSpan t = (End - Start);//Only used for timing
  22.  
  23.     return retval.ToString();
  24. }
  25.  
Sep 29 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3111
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
20
3299
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 speed. I like books with practical exercises, and also with test questions (like cert books) *2*
21
2821
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 applications or do I need to learn both VB.NET and ASP.NET. Thank you. TAM
9
2751
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 site (http://localhost) and I get error 'HTTP/1.1 503 Service Unavailable' when trying to start a new ASP.NET project. I uninstalled IIS and...
132
4752
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 it seems that C# became the darling of the ASP.Net crowd. In the meantime, I have observed an interesting phenomenon. Originally, employers hired...
16
2143
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 database using ASP.NET. I think the problem is somewhere in my connection string, but because I do not know much about connection strings, I am not...
2
1222
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 information and expertise. Please avoid personal attacks, slurs and profanity in your posts. A FAQ is a list of Frequently Answered Questions; ...
0
1509
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 Newsgroups allow users of Microsoft products to exchange technical information and expertise. Please avoid personal attacks, slurs and profanity in your...
13
1603
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 the original page. I have rechecked the links and they are set right, & work on local computer, but not on hosted site. I have noticed that when you...
13
1535
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 dont need 3 chapters on object oriented programming or c# inside a asp.net book. Looking mainly for reference books or tactics books that would...
0
7666
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
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
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
7644
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...
1
5484
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
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

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.