|
I use Directory.GetFiles to grab the names of files in the specified directory. How can i specify how many of files i need to grab through this command. For example, in a folder have 100 files, but i just need to grab 10 files each time.
Thanks!
|
|
|
|
|
my solution for this is use Directory.GetFiles to get all the files and put into a string array then go through the array to get certain amount of files back.
thanks!
I am Entry level person
|
|
|
|
|
i wrote a simple code as below:
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
' Only get files that begin with the letter "c."
Dim dirs As String() = Directory.GetFiles("C:\Documents and Settings\Max\Desktop\software engineer", "*.ppt")
'MsgBox("The number of files starting with c is {0}." & dirs.Length)
Dim dir As String
Dim i As Integer = 0
For i = 0 To 4
dir += dirs(i)
Label1.Text = dir
Next
Catch ex As Exception
MsgBox("The process failed: {0}", e.ToString())
End Try
End Sub
End Class
I am Entry level person
|
|
|
|
|
Thanks for the reply.
But the problem is the system is slow down with command directory.getfiles when there is a huge number of files in the specified path. The files in that path are accumulating fast.
any idea ?
|
|
|
|
|
You'll have to write your own implementation of .GetFiles() . The one you're using doesn't support just getting X number of files at a time.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks, Dave Kreskowiak!
what is the idea behind this .GetFiles()? Go to path, order those files by creation time, and grab it one by one to x number?
Need your advice, Thanks!
|
|
|
|
|
What do you mean?
.GetFiles() just gets all of the filenames in a directory. It doesn't do any sorting.
If you want a sorted list of files by date/time, even if you wanted the newest 10 files, you'll have to read the filename for all the files in the directory, sort them, then take the top 10. There's no way around this.
Now, if you could get away with this, you move the files you've already processed to another folder. This way, you're not trying to read the filenames of a 1,000 files just to sort them by date/time and then process the top whatever number of files. It's just when you're done with them, move them so you don't end up reading the same filenames over and over.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the idea!
|
|
|
|
|
Hi all,
I am runing an application which will check URL in my database there are around 3000 url in my database and i use .net http response and request to check the url the following are the code snippet..
Public Function checkurl(ByVal url As String) As String
Dim req As System.Net.HttpWebRequest
Dim res As System.Net.HttpWebResponse
Dim r As System.IO.StreamReader
Dim ex As Exception 'error exeption holder
Dim pge As String 'page holder
Dim title As String
Dim strreturnstring As String
'url = "http://www.getforme.com/e404.htm" ' not working becos have charset =ISO - 8859-1
'url = "http://environmentalchemistry.com/" not working becos have charset = iso - 8859-1
'url = "https://www.iclub.com/investorama.html"
Try
'display request url
req = req.Create(url)
req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)"
req.AllowAutoRedirect = True
'get page
res = req.GetResponse()
r = New System.IO.StreamReader(res.GetResponseStream())
'pge = r.ReadToEnd
r.Close()
res.Close()
strError = "OK"
status = "True"
'Convention is First Value is the Status and Second value is Errmsg
strreturnstring = status & "~" & strError
Return strreturnstring
Catch ex
status = "False"
strError = ex.Message
strreturnstring = status & "~" & strError
Return strreturnstring
End Try
End Function
my code working fine but the problem is when my code run URL which as charset = iso - 8859-1 or charset = windows - 1252 it just thro exception that The remote server returned an error: (400) Bad Request. or The underlyng connection is close..
can any one tell the reason why,
Thanx for your interest
regards
cyus
|
|
|
|
|
I use visual studio .net to develope a website. I have run the project on my local machine and it works fine, and all the requiredvalidators and rangevalidators work correctly.
To upload the site to the remote server, which is actual host of the site, I compile .dll files and put both .dll and .aspx files onto the remote server and access the site from actual web url, all the validators do not work at all. For example, a form with several required fields can be submit even when all the fields is empty.... I have no idea what I missed.
Could anyone here help me out?
Thanks in advance.
|
|
|
|
|
Did you just FTP the files into place or did you actually make a Setup Project for it an deploy that to the production server and run it?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I just FTP the files into the wwwroot folder on the remote server. I did't do Setup stuff. All the projects I have done are in ASP. This is my first asp.net project, I really don't have ideas about how to setup remote server running environment. How should I setup it? Could you please give me some details?
Thank you very much!
|
|
|
|
|
I got the solution to my problem from 4guysfromrolla.com
The problem is
aspnet_client\WebUIValidation.js on the remote server was missing.
|
|
|
|
|
I have made an installer with third-party tool "Setup Factory 6". After installing when I run application it causes an error about Object Initialization of some control. I have analysied all the dependencies and included them in installer.
Any solution?
Shoaib Nawaz
|
|
|
|
|
You'd be much better off asking this on a board that supports Setup Factory, like SetupFactory.com.
I use Wise for Windows Installer myself.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I get an error "Operator '=' is not defined for types 'System.Drawing.Color' and 'System.Drawing.Color'"
I am trying to do this:
if lblslots.BackColor = System.Drawing.Color.Red then
endif
Not a real big deal if I do not get an answer, more curious than anything else...
|
|
|
|
|
It's correct, there is no "=" operator defined for the Color structure. There is a method called Equals() though:
If lblSlots.BackColor.Equals(Color.Red) Then
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
DO u guys know How to transfer crystal report group tree into pdf bookmarks while exporting?
Help is appreciated.
|
|
|
|
|
HELP!!!!!!!!!!!!!!!
CAN YOU HELP BY PROVIDING CODE FOR CONVERTING TEXT FILE
INTO SQL TABLE USING VB.NET.
please post codeing as it is urgently required.
MY E-MAIL address as mention below.
u_rock100@rediffmail.com
|
|
|
|
|
This isn't as "generic" an operation as your question implies.
You have to write the code to open a text file, and read it, line-by-line. OK. This is pretty simple.
Hears the simple, but oh-so-tedious part. Each one of those lines has to be parsed up into the various fields that your require and put into variables to validate and hold those values. Once you have to data in those variable, you would probably run a stored procedure on teh SQL server, passing in those variables, to add the new data to whatever tables you need it to.
Back to very simple again, when you done reading the file, close it.
Writing this for you is out of the question. That's not how this forum works. If you want it written for you, go to www.rentacoder.com and spend way-too-much money to have someone do it for you.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm writing a simple Windows App with one form - Form1.
I want to automatically close this form upon the execution of some code - not a click event or any other user-initiated event. I need some ideas. Once control has passed from the code to the form (Sub New() and InitiateComponent), I'm stuck.
I've tried using Form.Close, and MyBase.Close and Application.Exit. It may be that I'm placing these in the wrong sequence.
|
|
|
|
|
Perhaps I'm not understanding your question, but Me.Close worked just fine. Created a new windows application, dropped one button on the form:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e _
As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Ran it, clicked the button, program ended. I think in .NET your application is active as long as there is any form loaded, even if you close the "main" form.
-- modified at 11:27 Tuesday 11th October, 2005
Nope, just checked, if you close the main form the program ends even with another form loaded.
|
|
|
|
|
I take it your trying to close the form from its own Load event? You can't. A form cannot close itself from inside its own OnLoad event.
If you're doing some processing to determine if the form needs to be show, do it before you even instantiate the form. The form should be responsible for all of the input and processing of certain data. It should not be responsible for determining if it should be shown at all. This is business logic that should not be in the User Interface layer.
If you're trying to show status information on a form during processing, consider rewriting this code into it's own class that exposes events that a UI layer can use and show any which way it wants.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
dim frm1 as new form1
frm1.topmost = true
frm1.show
'process
'process
'process
'process
frm1.close
or
create a seperate sub from the from-load event
then call the sub
like so
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call CLOSEME()
End Sub
Sub closeme()
Me.Close()
End Sub
hope it works
Marvin N. Guerrero
- Taje Kage_bunshinNunJutsU
|
|
|
|
|
dont mind can u pas the same to me if u get the rep.
|
|
|
|