|
I guess it will all depend on the size of the input file....
Perhaps a tweak to the "while" loop inside your cleanFile() function may help speed things up:
Private Sub CleanFile()<br />
'Read file line by line<br />
Dim file_name As String = "c:\Scanning files\lsprint_MO.txt"<br />
Dim Temp_file As String = My.Computer.FileSystem.GetTempFileName<br />
Dim textline As String<br />
<br />
If System.IO.File.Exists(file_name) = True Then<br />
Dim objReader As New System.IO.StreamReader(file_name)<br />
<br />
Do<br />
textline = String.Concat(objReader.ReadLine(), ControlChars.NewLine)<br />
<br />
If textline.IndexOf("xxxxxxx") = 17 Then WriteFile(Temp_file, textline)<br />
<br />
Loop Until textline Is Nothing<br />
<br />
objReader.Close()<br />
My.Computer.FileSystem.DeleteFile("c:\Scanning files\lsprint_MO.txt")<br />
My.Computer.FileSystem.RenameFile(Temp_file, "c:\Scanning files\lsprint_MO.txt")<br />
End If<br />
End Sub
Other than that, I'm affraid I have no ideas.....
Regards,
Martin
|
|
|
|
|
Hi all,
I am writing a VB.Net application that has a Command Prompt, which is running as a hidden process and I am redirecting the standard input/output from this process to my own user interface.
Everything seems to be working fine for regular DOS commands, for example; If I type "DIR" into my user-interface it displays exactly the same as if I'd typed DIR in to a command prompt window -- no problems there....
If I enter the name of an executable that is a windows based application, for example notepad.exe, then nothing seems to happen. If I then close my application the program I tried to start (i.e. Notepad) magically appears.
Having delved a bit deeper into this, I notice that after executing the notepad.exe command in my user interface, task manager is showing a "notepad.exe" process running but its not visible. I tried executing the dos command "start notepad.exe", and hey presto - the Notepad application starts up and is immediately visible.
Does anybody have any ideas as to why my hidden command prompt process is not making windows based applications immediately visible (unless they are proceeded by the "start" command)??
Thanks,
Martin
|
|
|
|
|
I can duplicate your problem, but I can't figure out why it's doing what it is. I think it has something to do with UseShellExecute , but you don't have much of a choice there considering you can't redirect the Streams without it being False .
The reason I say this is because you start the CMD process WITHOUT the shell. Any process that's launched from that CMD will ALSO not be launched from the Shell. The START executable gets around that by creating a new instance of the Shell and launching your command line through that (I THINK!). Funny thing is that you can't launch your hidden, or otherwise, CMD process with "START CMD.EXE" while UseShellExecute is False ! You also can't tell your successfully launched hidden CMD process to launch another CMD process using START ("CMD.EXE /K START CMD.EXE") without a Win32 error stopping you.
Sorry, it looks like there is no way around this that I can think of...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks a lot for having a look into my problem Dave,
You have provided a brilliant analysis, and I guess its a limitation I am going to have to live with....
Best regards,
Martin
|
|
|
|
|
Hello friends,
I have to create an application through which client can take backup of other machines on server machine(in LAN).
So primarily I want to create server application which can copy simple text file from client machines(in LAN) and save them on server machine.
I am new in .net and not getting how I should start?........I hope some experts can help me out.
Please help me to solve this situation it's urgent.....
Thanks,
Nagraj.
|
|
|
|
|
If you're familiar with how Windows networking works (folder sharing stuff), then this should be as easy as a file copy. But, it depends on how your network is setup. Domain or Workgroup? Are you going to be doing this as a service on the server? Are the workstation names available to your or are you going to have to type them in yourself? Do you have a single account that has access to all of the machines and gives you the permissions you need to get at the files you want to backup?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks Dave Kreskowiak for response,
I haven't worked on network project uptill now.
we have setup our network in workgroup and I have list of computer names in workgroup.
I hope u will explain something in detail.
Regards,
NAgraj
|
|
|
|
|
OK. You better start by learning Windows Networking first. A workgroup environment makes this MUCH more difficult because each machine in the workgroup keeps it's own list of user accounts that don't work on any other machine in the group.
Along with the list of machine names, you'll also need a username and password that gives you access to the files you want to backup, for EACH machine you want to copy files from!
Basically, you've going about this backwards. Don't write an application that pulls files down from each client. Turn it around and write an application that runs on each client and copies the files you need to the server. That way, your app can either depend on the user account that is logged in on each workstation to get access to the server, or the clients all use a single account on the server to login to it and copy the files.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am trying to deserialize data into a class with a different name from that which was serialized. I believe the solution should be simple with a SerializationBinder but this doesn't seem to work if the class contains an enumerated member.
The simplified example below throws ArgumentException: "Object of type 'SerializationTest.NewClassToDeserialize' cannot be converted to type 'SerializationTest.OldClassToSerialize+eBar'."
-------------------
Module TestModule
Sub Main()
Dim tOldObject As New OldClassToSerialize
tOldObject.Foo = "My Data Value"
' Serialize object in old format
Dim tFilePath As String = Path.GetTempFileName()
Dim tBinaryWriteStrm As FileStream = File.Create(tFilePath)
Dim tBinaryWriteFomatter As New BinaryFormatter()
tBinaryWriteFomatter.Serialize(tBinaryWriteStrm, tOldObject)
tBinaryWriteStrm.Close()
' Deserialize object in new format
Dim tBinaryReadStrm As FileStream = File.OpenRead(tFilePath)
Dim tBinaryReadFomatter As New BinaryFormatter()
' Override binding to bind to NewClassToDerialize
tBinaryReadFomatter.Binder = New MyBinder
' Enum leads to ArgumentException
Dim tNewUntypedObject As Object = tBinaryReadFomatter.Deserialize(tBinaryReadStrm)
tBinaryReadStrm.Close()
Console.WriteLine(tNewUntypedObject.ToString)
Console.ReadLine()
End Sub
End Module
<Serializable()> Public Class OldClassToSerialize
Public Enum eBar
EnumVal1
EnumVal2
End Enum
Public Foo As String
Public Bar As eBar
End Class
<Serializable()> Public Class NewClassToDeserialize
Public Foo As String
Public Bar As OldClassToSerialize.eBar
End Class
Public Class MyBinder
Inherits SerializationBinder
Public Overrides Function BindToType(ByVal assemblyName As String, ByVal typeName As String) As System.Type
Return GetType(NewClassToDeserialize)
End Function
End Class
--------------------
It works fine if you comment out the member 'Bar'! Can anyone tell me how to handle the enum?
Many thanks,
Nick
|
|
|
|
|
I want to know how i can read/write from USB port in vb.net?
|
|
|
|
|
The USB port doesn't work like a serial or parallel port. You have to write your code to communicate with a specific device attached to the bus. How you do that depends entirely on the device your trying to do something with.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello
I am using VS 2005 CR 10.
I am using typed datasets to populate a report.
From my database I have 1 field called incidentDate, this is a smallTimeDate datatype.
My reports always displayes the correct date, but is followed by the time which is always 12:00. For example 18/12/2006 12:00 AM.
I don't want to display this time. I have tried setting the DateWindowsDefaultType in the report properties for that field. But this did not work.
Does anyone have any other ideas,
Thanks very much,
Steve
|
|
|
|
|
How about trying CStr({@Date},'MM/dd/yyyy')). I dont have the IDE with me so check for the correct syntax
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
Experience is like a comb that life gives you when you are bald - Navjot Singh Sidhu
|
|
|
|
|
<br />
Imports WMPLib<br />
' used to import the windows media player lib<br />
<br />
i can create a play list, play selected media and all that but i can't get it to select a play list from file and play it . i looked briefly at the "currentplaylist" and other IWMPPlaylist but they only have functions that adds to a play list. i just want to simply select a play list from a storage area of choice.
any help would be appreciated. thanks in advanced.
p.s. Bless up NCU and Bless up Jamaica.
c.smith
|
|
|
|
|
Hello,
I am writing a problem that populates a combo box. When the user selects something from the combo box, they will press a tab key that will take them to the next control. However, i have tried using the keydown, keyup, and keypress. All these capture the other keys but not the tab key.
Sample of what I am trying to do.
Private Sub ComboCompany_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboCompany.KeyDown<br />
If (e.KeyCode = Keys.Tab) Then<br />
MessageBox.Show(Keys.Tab)<br />
Else<br />
MessageBox.Show(e.KeyValue)<br />
End If<br />
End Sub<code><br />
<br />
many thanks for your help,<br />
<br />
Steve
|
|
|
|
|
What exactly are you trying to do?
You could use the leave event of the combobox to know when the focus moves from the combobox to any other control on the screen.
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
Experience is like a comb that life gives you when you are bald - Navjot Singh Sidhu
|
|
|
|
|
Yes the leave event would be a better option because a windows form intercepts the tab key. Leave event would be a hassle free workaround.
Posted by The ANZAC
|
|
|
|
|
Hello All!
Seems pretty simple, but this is my first attempt at printing. There are alot of options when it comes to printing. All I need to do is click on a button, and have that event print a pre-selected text file. Just a file created in notepad, 4 lines of text. I don't need to preview it, and just use the default printer. I don't need the user to set up any settings, just hit the print button, and that text file will get printed. What is the easiest way to accomplish this?
I'm working in VS 2003, vb.net.
Thanks!
Rudy
|
|
|
|
|
you can use 'print document' component from the toolbox and handle the printing event for that component. something like using grapics.drawstring function
|
|
|
|
|
I am working on a project that requires the ability to view a tiff file and be able to zoom in and out. Anyone know of a control that can do this in VB.Net 2005?
Thanks
Simmy
|
|
|
|
|
If you want that kind of functionality written for you, then you'll either have to look for a 3rd party component to do it for you or write it yourself.
Either way, you'll need to either write or find a 3rd party component to support TIFF files anyway, because TIFF support in GDI+ is limited. There is no support for JPEG compressed TIFF files in GDI+, and hence, no control that depends on GDI+, like the PictureBox control, will work with them.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
does anyone know of some sort of freeware program that can analyse a .net component or application so see how its made up?
Im guessing some sort of reflection?
Regards
Mark
|
|
|
|
|
There is nothing that will "analyze" it for you. I have no idea what you mean by "see how it's made up". But, there is always the most indispensible tool on the planet Earth -> Lutz Roeder's .NET Reflector[^]
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
if you want to look at the manifest and stuff you can use ildasm.exe.
You can only be young once. But you can always be immature.
- Dave Barry
|
|
|
|
|
Full Source Code For Advanced HTML Editor v1.2:
Features:
Edit multiple files at a time,
Preview in the built-in browser,
Complete help for all html tags,
Insert tags from the help panel,
Dialog boxes for all html tags,
No need to manually code every tag.
Advanced features of visual basic are used in this project. The source code is fully commented and easy to understand.
The source is free to use in your projects, but requires my permission befor distributing to anyone.
To download the source code for the project follow the links below..
http://rapidshare.com/files/7869936/THE10.rar[^]
http://www.megaupload.com/?d=3VSBMGRH[^]
nagarjuna
|
|
|
|