|
Hi,
for file I/O you don't need Peek() at all, just create a loop and test the ReadLine() result, see here[^].
And for small files, read all at once using File.ReadAllText() or File.ReadAllLines().
You would need Peek() pr some other blocking call if the data is streaming in slowly, say in networking; but not for files.
|
|
|
|
|
I'm trying to zip a folder in the .net framework 2 (Customer wants this, not me). How do you do this?
|
|
|
|
|
Preserving the conditions of GPL license, you might use SharpZipLib[^].
|
|
|
|
|
So I should add this to MS Visual studio and use the libraries?
|
|
|
|
|
Well, errr, depending on what you understand by "add this to MS Visual Studio". If you mean that you have to add a reference to this library in your project, the answer is yes, of course.
|
|
|
|
|
Thanks Erik... I'm new to visual studio. So I'm a lot right now
|
|
|
|
|
We have a GZipStream[^] class. You can make use of that to create zip files.
|
|
|
|
|
i want to increase the space between to record front the front end by passing value as a parameter like 1,2,3
that should increase line spacing by 1,2,3 lines
how can i achieve this plz help
|
|
|
|
|
Please do not post in multiple forums; see this message[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi,
I'm changing the text of an application writtewn in vb.net using the user32.dll method "SetWindowText".
The text of the application changes but the textchanged event for the form doesn't fire off.
Is there anything I need to do after sending the "SetWindowText" to the recieving app to fire off the even or something within the app itself?
Thanks,
Chris
modified on Thursday, October 28, 2010 6:14 AM
|
|
|
|
|
Of course it doesn't fire. You completely bypassed the .NET code that would have fired the event had the text been changed through the Forms Text proprty settor when you sent the message directly to the windows message pump.
There is nothing you can do to force the target app to fire off it's TextChanged event when you used this method.
Short of extrodinary difficult effort (read: not worth the cost to develop), I don't see how you're going to pull this off.
|
|
|
|
|
You should use SendMessage function to send a WM_SETTEXT message instead. SetWindowText will not cause this message if the target window is not owned by the same process you are making the call, and if WM_SETTEXT is not sent, TextChanged event will not be fired.
Anyway, I think this question should be in Windows API forum.
|
|
|
|
|
Thanks for the hint.
I solved the problem like this:
Using the following declarations:
Public Declare Function apiFindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
Public Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As String) As Boolean
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr
Private Const WM_SETTEXT As Integer = &HC
I then search for another instance of the application and send the message with the relevant details if it finds one.
Dim window As IntPtr = apiFindWindowEx(Nothing, Me.Handle, "WindowsForms10.Window.8.app.0.378734a", "PDF Viewer")
If Not window = 0 Then
SendMessage(window, WM_SETTEXT, 0, Command())
Me.Close()
End If
Then in the application (it's the same app but I only want one open at a time) there is this piece of code that checks the messages when they're recieved:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
If m.Msg = WM_SETTEXT Then
If justopened = True Or Me.Text = "PDF Viewer" Or Me.Text = "File Browser" Then
Else
pdfrecieved(Me.Text) 'goes and does stuff
End If
End If
End Sub
Thanks for the help!
|
|
|
|
|
Hi,
How to map drive by checking domain name when user log on,such as when user log on domain 1 map network drive = X
and if user log on domain 2 map netwrork drive =Y
I have write a script it as below details,tt seemed didn't work.Plese help. Thanks in advance
Option Explicit
Dim objSystemInfo
Dim objWSHShell
Dim strLogonServer
Dim objNetwork
Dim strDriveLetter, strRemotePath
Set objWSHShell = Wscript.CreateObject("Wscript.Shell")
strLogonServer = objWSHShell.ExpandEnvironmentStrings("%LOGONSERVER%")
WScript.Echo "Server Name is :" & strLogonServer
Set objSystemInfo = CreateObject("ADSystemInfo")
WScript.Echo "Site Namen is: " & objSystemInfo.SiteName
strDriveLetter = "X:"
strRemotePath = "\\domainname\home\"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
WScript.Quit
|
|
|
|
|
I don't exactly what you're looking for because your code doesn't check which domain the user logged into. But, here's an example of where the det the domain name:
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "Domain = " & WshNetwork.UserDomain
|
|
|
|
|
Thank Dave
How to check domain if i have multiple domain and map network drive. Thanks in advance.
|
|
|
|
|
Why don't you use a script in the 'NETLOGON' share of one of the DC's of the domain you're connecting to ?
|
|
|
|
|
Hi,
Because of user working on multiple domain. I can't specific drive for them. I think it should be check domain before map network drive. Plese suggest me. Thank you
|
|
|
|
|
|
What did I tell you about posting this crap?
|
|
|
|
|
The NETLOGON share exists on any domain controller of any Active Directory domain.
There you can put some scripts that will be executed for users, if activated in their account management window.
Thus, the only things you have to do are :
- create a script (.bat or .cmd) in the netlogon share of one of the domain controllers that will connect a given drive letter to a given share on a particular server
For example :
net use H: \\myserver\users$\%username%
net use I: \\mysecondserver\common
- in the user's account management window, just give the filename of your script in the 'Connection script' field
The script will be executed when the user opens his session.
If you do that on both domains, no need to check for which domain is involved : the entire login process will take care of that for you.
|
|
|
|
|
Considering I already showed you how to get the domain the user is in, writing the IF statement to see if it matches whatever your requirements are for a particular drive mapping is on you.
|
|
|
|
|
Hi
I have write it as below details;
Set WshNetwork = WScript.CreateObject("WScript.Network") WScript.Echo "Domain = " & WshNetwork.UserDomain
strDriveLetter = "J:"
strRemotePath = "\\Domain\home\"
It didn't map network drive. Plese suggest me. Thank you
|
|
|
|
|
I can't tell you the exact code to use.
I have no idea what you're checking for (not that your code does ANY checking of anything what-so-ever!) and no idea what your server name and share names are. If this code is EXACTLY what you are running (no substituting "Domain" for anything,) you also do not know enough about Windows networking to take an intelligent guess at what you're supposed to be doing.
You cannot map a drive to a Domain. You map a drive to a \\<ServerName>\<ShareName>.
|
|
|
|
|
Thank you Dave. I will learn more.Sorry for make you confusing.
|
|
|
|