|
Thanks for the response. I think I understand. Some comments...
I set up a test FTP folder:
FTPServer = "ftp://ftp.maroisconsulting.com/test",
UserName = "FTPTest",
Password = "testftp"
When I run the code, I get the exception:
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
I'm sorta lost here. I don't understand why this doesn't work. The folder exitst with 2 test files in it. My FTP Client (FileZilla )works, but not this code.
Everything makes sense in someone's mind
|
|
|
|
|
Based on the error number, your FTP client is connecting and authenticating without any problems. The problem seems to be realted to the server. It's possible that that access is denied to the file/directory (either by permission or file lock). If you have access to the server, verify the permissions for user FTPTest. You also might want to verify that the FtpWebRequest object credentials match your FileZilla settings exactly.
You could also try it against another FTP server you have access to and verify it. You code works for me when I tried it against both anonymous servers and my own.
|
|
|
|
|
Thanks Matt. That's good to know.
Everything makes sense in someone's mind
|
|
|
|
|
I am attempting to accomplish 2-way synch from a DataGridView to a table in my database. DGV to table is easy, but is there a "best practice" way to have the DGV automatically update to reflect any changes made to the database?
I tried using a timer and perform a TableAdapter.Fill(DataSet.SomeTable) at regular intervals, but the problem with this approach is that it "clobbers" any edit in progress, and resets the selected row to the top. Preferably, I would avoid impacting the user so directly.
Thank you...
EDIT: Here is how I am synching DGV changes to the database:
private void dgvSomeView_RowValidated(object sender, DataGridViewCellEventArgs e)
{
myTableAdapter.Update(myDataSet.MyTable);
}
|
|
|
|
|
I think I found what I need: the SqlDependency class.
Looking into it now...
|
|
|
|
|
Can u help me optimize this functions? There are labels array5*5.
if Label[i,j] has symbol then IsEmpty[i,j] has false if it hasn't IsEmpty[i,j] is true;
Funcktions for game Royal Square )
public bool IsOpenForLetter(bool[,] IsEmpty, int x, int y)
{
int imin, imax, jmin, jmax;
int xSize = IsEmpty.GetLength(0);
int ySize = IsEmpty.GetLength(1);
if (IsEmpty[x, y])
{
if (x > 0) imin = x - 1;
else imin = x;
if (y > 0) jmin = y - 1;
else jmin = y;
if (x < xSize - 1) imax = x + 1;
else imax = x;
if (y < ySize - 1) jmax = y + 1;
else jmax = y;
for (int i = imin; i <= imax; i++)
for (int j = jmin; j <= jmax; j++)
if (!IsEmpty[i, j])
return true;
}
return false;
}
public bool IsItNear(int fx, int fy, int sx, int sy, bool[,] IsEmpty)
{
bool[,] Action = new bool[3, 3];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
Action[i, j] = true;
int ftx, fty, sdx, sdy;
ftx = fx; fty = fy; sdx = sx; sdy = sy;
if (sdx == 0)
for (int i = 0; i < 3; i++)
Action[0, i] = false;
if (sdy == 0)
for (int i = 0; i < 3; i++)
Action[i, 0] = false;
if (sdx == 4)
for (int i = 0; i < 3; i++)
Action[2, i] = false;
if (sdy == 4)
for (int i = 0; i < 3; i++)
Action[i, 2] = false;
Action[1, 1] = false;
sdx--; sdy--;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
if (Action[i, j] == true)
if (IsEmpty[sdx, sdy] == false)
if (sdx == ftx && sdy == fty)
return true;
sdy++;
}
sdx++; sdy=sy-1;
}
return false;
}
|
|
|
|
|
This looks like homework...
|
|
|
|
|
It's part of my programm and programm is homework...
|
|
|
|
|
Why do you want us to do your homework for you? We'd better serve you by allowing you to learn for yourself... These are concepts that you will need to master, you know.
|
|
|
|
|
He showed he tried something , whether it is homework or not is irrelevant.
V.
|
|
|
|
|
What if the assignment was "optimize this (provided) code"?
Regardless, your other post seems to point him in the right direction.
|
|
|
|
|
If don't want to say how i can do it or give idea for it write this. I've written this this function for my programm but they are big. I'd like to know how i can do it use less actions. Maybe anyone has idea How i can do it.
|
|
|
|
|
I don't know this game, but here are some pointers:
1. Always use { and } even on single statements.
2. Avoid multiple returns
3. As I said, but why are you using and IsEmpty boolean array which I assume is 'synchronized' with the labels array? You can pass your labels array and check whether the label is empty or not. eg( string.IsNullOrEmpty(lbl_array[x,y].Text) )
4. You don't check if x and or y is within the array size, you can get an arrayindexoutofboundsexception error
5. You hardcode all variables, if you want to change the game to a 10*10 matrix you'll have a fun time changing all the variables.
6. make sure you name your variables so they mean something. I have no idea what fx, fy, sx, sy, ftx, fty, ... are for.
7. One statement, one line avoid: sdx--; sdy--;
this should help you already.
Don't mind the homework remark, you showed you tried something yourself, whether it is homework or not is irrelevant.
V.
|
|
|
|
|
Those don't really have anything to do with optimisation, and most of them (1, 2, 6 and 7) are matters of opinion, of which I only agree with one (6, and even then, those names might well be meaningful if you know the game).
|
|
|
|
|
BobJanova wrote: Those don't really have anything to do with optimisation
Depends on what you mean with optimisation.
BobJanova wrote: which I only agree with one
You don't have to agree, but I wouldn't want to debug your code if you write it like that. (I'm not saying your code is bad nor is it wrong)
V.
|
|
|
|
|
BobJanova wrote: of which I only agree with one
Then you are missing good code standards used by most professionals
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I'm not missing them, I just don't agree with them
(Or, to be less glib, they come from good principles, but when applied as fixed rules, they make things less readable, generally by expanding the code so that you can't see the pattern of it any more. In the case of the example posted here, decrementing both the x and y variables in one line makes sense because it's one thought, for example.)
There is nothing wrong with multiple returns, though. Checking a condition within a foreach loop and returning when it's hit is quite common and perfectly readable (arguably more so than assigning to a variable and break ing since you can see that it's an exit point).
|
|
|
|
|
To each there own. There is no learning when the mind is closed. Hope I don't have to pick any code you have been working on.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
"There is no learning when the mind is closed."
Quite. I'm glad you agree with me that fixed rules such as those I was responding to are not a good idea, and one should keep an open mind as to what the situation you're coding for requires.
|
|
|
|
|
V. wrote: You can pass your labels array
Not if you need to do a search to find your best next move. I'd use an int.
|
|
|
|
|
First of all, I'd ask you whether or not optimisation is really necessary. Quite often you'll spend a lot of time looking for optimisations which, strictly speaking, aren't necessary. You may save a clock cycle here or a clock cycle there, but it's not noticeable.
As for optimisations, the most obvious one that I see lies here:
if (Action[i, j] && !IsEmpty[sdx, sdy] && sdx == ftx && sdy == fty)
return true; Please though give your variables better names, and use { } to wrap code sections; I had real trouble wading through the logic.
|
|
|
|
|
I don't see very much there to optimize while keeping the same data structures.
Using an array of arrays can be faster than a 2D array. Using a BitArray instead of an array of bools is usually faster. If the array is sufficiently small, using the bits in an ulong directly is even faster, and you should probably look up bitboards if this is about a game board (and that's what it is, isn't it?)
edit: if you explain what the code is supposed to do, maybe I can help you sort out bitboard functions.
|
|
|
|
|
I have square 5*5.(Labels array) some of them Empty. other have symbols. bool IsEmpty 5*5 contains true if Lable is Empty or false if label has symbol.
first function:
When i do click on label first function cheks Label[x,y] is empty or not. if it is empty then it checks labels which near it if they have a symbol function return true;
second functions:
for select a word when i do click on labels.
I click on labels programm write cordinats label;
then i click next label function need to check if it has a symb and near first label then return true;
fx,fy are first label
sx,sy are second label
|
|
|
|
|
I'm sorry to say it, but your English wasn't very good so I can easily misunderstand what you mean, so please correct me if I'm wrong.
First function:
bool IsOpenForLetter(int x, int y, ulong isempty)
{
int index = x + 8 * y;
ulong isnotempty = ~isempty;
return ((isempty >> index) &
(isnotempty >> (index + 1)) &
(isnotempty >> (index - 1)) &
(isnotempty >> (index + 8)) &
(isnotempty >> (index - 8)))
!= 0;
}
edit: it doesn't check whether it would go out of bounds, because it isn't needed thanks to the padding.
Second function: I'll try this one later
|
|
|
|
|
Hi,
I have been developing add-ins for MS Word for quite some time now. I usually track bind failures using Fusion Logs and it used to work for all applications. But suddenly, the fusion logs fail to catch any load events for WINWORD.exe. I do not get any entries in my "C:\fusionlog\DEFAULT" folder for WINWORD.exe. It works fine for EXCEL.exe, POWERPNT.exe. I wanted to check fusion logs because my addins did not load in MS Word but the addins loaded in Excel and PowerPoint. Could anyone please help?
Thanks,
Ram
|
|
|
|
|