|
|
I translated several Windows Forms from german to english. I simply set the Localizable property in the Windows Forms Designer to true and changed the Language property to German.
But I made a mistake: The language "(Default)" now contains German texts and the language "German" contains the English texts.
Question: Is there a way to "swap" this without the need to painfully edit the .resx files by hand?
--
Affordable Windows-based CMS for only 99 €: try www.zeta-producer.com for free!
|
|
|
|
|
Public Function isChar(Expression As Variant) As Boolean
Dim str, I, length, ch
I = 1
str = Expression
length = Len(str)
While (I <= length)
ch = Mid(str, I, 1)
If Asc(ch) >= Asc("a") And Asc(ch) <= Asc("z") Or _
Asc(ch) >= Asc("A") And Asc(ch) <= Asc("Z") Or _
Asc(ch) = Asc(" ") Or Asc(ch) = Asc(".") Or _
Asc(ch) = Asc("-") Or Asc(ch) = Asc(",") Then
isChar2 = True
Else
isChar2 = False
Exit Function
End If
I = I + 1
Wend
End Function
Thanks
Monica
|
|
|
|
|
Have you even looked here?[^]
Hey don't worry, I can handle it. I took something. I can see things no one else can see. Why are you dressed like that?
- Jack Burton
|
|
|
|
|
public bool IsCharacter(string expression) {
bool success = false;
foreach(char c in expression) {
if(Char.IsDigit(c)) {
success = false;
break;
}
}
}
WM.
What about weapons of mass-construction?
|
|
|
|
|
Beside the fact your function returns nothing and wouldn't even compile (unless I add an extra return success - but in this case it always return false no matter what input you give to it), the IsDigit test is not even close to what the code of the op tested.
|
|
|
|
|
A line for line translation. Very quick and dirty, there is probably more efficent ways to do this.
public bool IsChar(string input)
{
bool isChar = true;
for(int loop = 0; loop < input.Length; loop++)
{
if((input[loop] >= 'A' && input[loop] <='Z') || (input[loop] >= 'a' && input[loop] <='z')
|| input[loop] == ' ' || input[loop] =='.'
|| input[loop] == '-' || input[loop] == ',')
{
isChar = true;
}
else
{
isChar = false;
break;
}
}
return isChar;
}
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
I have a project where I must send data to a remote FTP server using an Active FTP connection. I'm able to connect to the remote server fine, but when I send the "POST" command, the socket is not connecting. I get the following exception error:
"A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied"
I have looked all over the net for an example of sending the FTP "POST" command, but haven't found anything. What am I doing wrong? Working examples would be greatly appreciated.
Here's the code snippet I'm trying to use (let me know if you need more information):
private string GetPortParameters(int localPort)
{
string localHost = Dns.GetHostName();
IPAddress localIPAddress = Dns.Resolve(localHost).AddressList[0];
string strLocalIPAddress = localIPAddress.ToString();
strLocalIPAddress = strLocalIPAddress.Replace('.',',');
int portParam1 = ( 0xff00 & localPort ) >> 8;
int portParam2 = ( 0xff & localPort ) ;
string portParameters = strLocalIPAddress + "," + portParam1 + "," + portParam2;
return portParameters;
}
private int GetPort()
{
if ( dataPort > 30000 )
{
dataPort = 10000;
}
return dataPort++;
}
private Socket CreateActiveDataSocket()
{
int thePort = GetPort();
string portParams = GetPortParameters(thePort);
Socket portSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
IPEndPoint ep = new IPEndPoint(Dns.Resolve(Dns.GetHostName()).AddressList[0], thePort);
portSocket.Bind(ep);
portSocket.Listen(4);
SendCommand("PORT "+portParams);
SendCommand("STOR "+Path.GetFileName("C:\\somefilename.txt"));
portSocket.Accept();
// sending the socket back to the caller to transfer (upload) the file
return portSocket;
}
Eddie
|
|
|
|
|
I've written a full featured FTP client in java, The only command to upload stuff, as far as I know, is STOR. Before sending the STOR command you will need the PORT command. The following steps need to be done:
1. Make a socket that listens on a random port (use port 0 to initialize and get the actual port after the initialisation)
2. Send the PORT command.
3. Read the response and check if it's ok
3. Send the STOR command.
4. Write the file to the socket you created.
5. Read the response of the server and check if it's ok
It should work this way
WM.
What about weapons of mass-construction?
|
|
|
|
|
Thanks for the response, WM. The problem occurs in step 4 of your post. When I try to the file to the socket I created, I get the error that I previously posted. I need to know why the connection is not being established after sending the PORT command to the server.
Eddie
|
|
|
|
|
Are you behind a firewall/proxy something like that? It seems like the server couldn't connect to your socket. Check if the response on the STOR command is 150. If it isn't the server can't connect to your listening socket.
An alternative on the port command would be the PASV command in which case you connect to the server to post your file, instead of the server connecting to you.
WM.
What about weapons of mass-construction?
|
|
|
|
|
Yes, I do get a 150 response once the STOR command is sent. I have no problem with the PASV command at all.
This is what I do for PASV (this works):
1. Connect to FTP server w/ Username/password
2. Send the PASV command and read the response from the server
3. I parse out the IP Address and Port sent by the server in step 2
4. Create a new socket with IP/Port and connect to it.
5. Send the STOR command
6. Send bytes to upload file on the connection created in step 4
This is what I assume I should be doing for PORT:
1. Connect to FTP server w/ Username/password
2. Retrieve local IP and generate random port #
3. Create new socket with IP/Port from step 2, Bind and Listen
4. Send the PORT command with the IP/Port generated in step 2 (I receive "200 Port command successful" from server)
This is where I'm unclear on what to do next. I'm assuming that the server will automatically connect to the port I just sent, but it doesn't seem to.
5. Send the STOR command (receive 150 response from server)
6. Upload file on connection that I'm listening on (Error occurs here).
The reason I'm trying to do it this way:
Our automated FTP program has been failing to send files to one of our clients in Passive mode. After we contacted them they asked that we try sending the files non-passive. What I find odd is that we receive a response from their server when sending the PASV command, but we can't connect to it. In fact, we can't even ping it. So, you might be right in that it could be a firewall issue on their end. Nevertheless, I was still tasked to get Active file transfers to work, but can't even do it on our local servers.
Any thoughts?
Thanks, Eddie
|
|
|
|
|
Are you writing a FTP server or a client? Your CreateActiveDataSocket() function attempts to listen on the specified port and host and then immediately does a SendCommand
Assuming you're writing a client, the correct code would be
private void ConnectToServer()
{
Socket socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
socket.Connect(new IPEndPoint(Dns.Resolve(Dns.GetHostName()).AddressList[0], 20));
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks Senthil. I'm writing an FTP Client. Assume that I'm already connected to the FTP server. After connecting, I want to FTP a file in Active mode. In order to do so, I create a new socket with my local IP and a random port and listen to it. I then send the "POST 192,168,xxx,xxx,xxx,xxx" command to the server which has my local ip and random port I just generated that I want the server to connect to. The problem is that it doesn't seem that the server ever connects with the IP and port that I sent, hence, the error in my original post. How do I make the server connect to my IP/port? I know I'm missing something.....
Thanks again for your help!
Eddie
|
|
|
|
|
I've never heard of the POST command. It doesn't seem to be a standard FTP command?
AFAIK, you don't need to create a local server socket on a random port and list on it. And the server won't attempt to connect to your client, it's the client who'll connect to the server.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
i want the title bars of both forms to show active at the same time. In WindowsXP default, both title bars would be blue instead of one being blue and the other form fading to light blue, it is possible (overriding windows messaging) i know, but how?
Can someone indicate me how?
|
|
|
|
|
Sasuko wrote:
it is possible (overriding windows messaging) i know, but how?
Actually I don't think it is possible at all. You could paint your title bar the same color even if it is inactive, but getting Windows to paint the caption as active when it isn't, no way. Only one window is active by definition.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi, I have a user thread and I need to tell it to run some code in the GUI thread. I was thinking that maybe I would use SendMessage and create a message handler for this but it sounds like more of a C/C++ way of doing it. Is there something in C# line this? Kind of like java has SwingUtilities.invokeLater()
-- Rocky Dean Pulley
|
|
|
|
|
Actually SendMessage is not directly implemented in the CLR.
You should use the BeginInvoke to call code in the UI thread from another thread.
Google for BeginInvoke and UI or read this article: http://www.codeproject.com/csharp/winformthreading.asp[^]
/cadi
24 hours is not enough
|
|
|
|
|
You can use BeginInvoke and Invoke on the System.Windows.Forms.Control class.
This[^] article explains the gory details.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello,
I encountered a strange problem and I do not know what is causing it.
I created an empty form, added a tabs control to it and set the tab control
dock style to fill. Then I added three tabpages to it. To the first tab page
I added three buttons. The first button's click handler would set the tab
control's tab alignment to TabAlignment.Left and the second buttons click
handler would set it to Bottom.
I added mouse enter and mouse leave handlers to the third button. Whenever
the mouse would enter the button, I would change its background color to
yellow. When the mouse leaves the button, I would set the color back to its
original state.
Now, when I start the form, the mouse enter/leave events work great and
everything is fine. However, once I change the tabs alignment by hitting one
of the first two buttons, the third button no longer fires it's mouse leave
event and only fires the mouse enter event once. The mouse enters and mouse
enter fires correctly, but it seems that the mouse leave event has been
unregistered when the tab control's tab alignment changed.
Does anyone know what can be causing this behavior and how to fix/avoid it?
Thanks,
-Flack
|
|
|
|
|
I'm attempting to connect to a MySQL database from my ASP.NET application (c#). Here's my code:
string connString = "Database=games;Data Source=http://[my server's IP]/mysql;User ID=group; Password=" + strSystemPasswords[3];
conn = new MySqlConnection(connString);
conn.Open();
The database is contained in the mysql directory under the web server's root. (I added a space between group; and Password to prevent a smiley.)
When I run the code, I get the following error for conn.Open():
"The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for "
I've researched the problem and have found the standard answer is that the address can't be resolved. However, I am assuming that this is not the problem in my case, as I can navigate to that exact address with my web browser. But I haven't found any alternate causes for this error.
Any suggestions?
Thanks for your help!
|
|
|
|
|
Your datasource is local to the server. ASP.NET is a server-side only technology that generates HTML for a client. Change your "Data Source" so your code is looking for it local to the server filesystem, not over an http connection.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok, I'm trying to capture text from a texbox inside of another program. In other words, I have a window handle of an exterior program. This program contains a textbox. I would like to capture that text. Is there a set of API commands that would enable me to do this? I've been looking on MSDN for a while and haven't found anything. Any help would be greatly appreciated. Until then, the searhc continues...
|
|
|
|
|
Try : <a href="http://www.pinvoke.net" rel="nofollow">http://www.pinvoke.net</a>[<a target=_blank title='New Window' rel='nofollow' href="http://www.pinvoke.net">^</a>]
|
|
|
|