|
I think you are talking about FTPS.
How can I use FTPS client in C# and is there a FTPS server for linux?
Thanks.
|
|
|
|
|
I think you're referring to SFTP[^], not FTPS.
|
|
|
|
|
Actually I am referring to FTPS not SFTP. Because SFTP is doing his job over SSH and I don't want to risk console access. I prefer using FTPS. FTPS is doing his job with using SSL for encryption.
|
|
|
|
|
Can Selçik wrote: How can I use FTPS client in C#
You can buy a library, or write the code yourself.
Can Selçik wrote: is there a FTPS server for linux?
Man, you're full of good questions today, aren't you?
I'm sure that if you took the time to use GOOGLE, you would find your answer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
When I open a page in the WebBrowser I see appear notice board:Security information
I want programmed to automatically remove this notice I do? I'm using language C #.NET
|
|
|
|
|
From inside a web page? You can't and for good reasons. For that purpose you would have to write your own (unsecure) browser.
|
|
|
|
|
Yes, I want to design a program WebBrowser.Toi will have a program like the user to browse the Web, the program will automatically answer the panel notification Security Information usually appears in a page.
|
|
|
|
|
trinm1987 wrote: Yes, I want to design a program WebBrowser
That's a HUGE undertaking for a single person. It normally takes entire TEAMS of people a few years to write a browser from scratch. Good luck with that...
|
|
|
|
|
public class StatusChangedEventArgs : EventArgs
{
private string EventMsg;
public string EventMessage
{
get
{
return EventMsg;
}
set
{
EventMsg = value;
}
}
public StatusChangedEventArgs(string strEventMsg)
{
EventMsg = strEventMsg;
}
}
public delegate void StatusChangedEventHandler(object sender, StatusChangedEventArgs e);
public static event StatusChangedEventHandler StatusChanged;
Okay, so in the above code, we created a delegate and a custom event.
public static void OnStatusChanged(StatusChangedEventArgs e)
{
StatusChangedEventHandler statusHandler = StatusChanged;
if (statusHandler != null)
{
statusHandler(null, e);
}
}
What does the bold line do? Why do we check for null?
EDIT: The code is from C# Chat: Part 2 - Building the Chat Server (C# Programming Tutorial) • Geekpedia[^] check that out, if the above code doesn't provides what I mean.
|
|
|
|
|
Hi,
you make a local copy of StatusChanged, so the same value gets used both in the null-text and the invocation; StatusChanged is public, so it could be changed by another thread at any point in time; removing the last handler from it right after the null-test got executed would cause an exception in statusHandler(null, e);
In summary, without it your code would not be thread-safe.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 12:01 PM
|
|
|
|
|
so the same value gets used both in the null-text and the invocation;
I'm sorry, but I didn't got it, what do you mean by null-text and the invocation?
I'm converting this code to C++/CLI so I don't know C#, that's why having little problems...
|
|
|
|
|
if (statusHandler != null) <--- that looks like a null-test
statusHandler(null, e); <--- according to the comment this is an invocation
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 12:02 PM
|
|
|
|
|
Hmmm, you wrote null-text
lol.. Thanks anyways
|
|
|
|
|
Isn't that just making a copy of the reference?
And therefore no safer than testing/invoking directly on the original reference?
Subvert The Dominant Paradigm
-- bumper sticker, circa 1971
|
|
|
|
|
Yes, it copies a reference, making sure the event and the delegates inside it can not be garbage collected (it is a local copy). There still is a possibility that the event gets changed (it is kind of a linked list), to cope with that you could (probably should) add a try-catch around the invocation.
This is one of those rare cases where an empty catch block would be fine: after all, if another thread is allowed to remove the last delegate, that really means there is no need to call it anymore.
Have a look at the fine article Giorgi provided.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 12:02 PM
|
|
|
|
|
ahhh... reference to empty versus null reference. Got it.
Now I have to rework a whole bunch of code... I foresee a generic solution
Subvert The Dominant Paradigm
-- bumper sticker, circa 1971
|
|
|
|
|
Luc's answer is perfect.
In addition, there's no need to declare your own delegate (from 2.0 onwards). Instead, just declare the event...
public event EventHandler<StatusChangedEventArgs> StatusChanged;
and in the OnStatusChanged...
EventHandler<StatusChangedEventArgs> statusHandler = StatusChanged;
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
|
Given the following code:
public class Employee1
{
public string Property1 { get; set; }
public Employee1() {}
}
public class Employee2:Employee1
{
public string Property2 { get; set; }
public Employee2():base() {}
}
public class Form1
{
List<employee1> m_employees = new List<employee1>();
private void Add()
{
m_employees.Add(new Employee1());
m_employees.Add(new Employee2());
}
private bool IsType(object item, string typeName)
{
bool result = false;
if (item != null && !string.IsNullOrEmpty(typeName))
{
result = (item.GetType().Name == typeName);
}
return result;
}
}
I want to add the items in this list to a ListView , but I have to cast the objects to their actual types, like so:
string[] listItems = new string[2];
if (IsType(obj, "Employee2"))
{
listItems[0] = ((Employee2)obj).Property1;
listItems[1] = ((Employee2)obj).Property2;
}
else
{
listItems[0] = ((Employee1)obj).Property1;
listItems[1] = "Not applicable";
}
I want something more generic (I want to avoid using the actual type names if possible). I tried to use various properties in the type object returned by Type.GetType("Employee2", true, false); as a casting mechanism, but nothing seems to work.
I want to do something like this:
string[] listItems = new string[2];
Type itemType = obj.GetType();
listItems[0] = (itemType)obj).Property1;
if (IsType(obj, "Employee2"))
{
listItems[1] = ((itemType)obj).Property2;
}
else
{
listItems[1] = "Not applicable";
}
Does anyone have any ideas?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote:
Does anyone have any ideas?
Usually, you do something like this:
Employee2 empl = null;
if (obj is Employee2)
empl = (Employee2)obj;
or you can do this:
Employee2 empl = obj as Employee2;
The latter will return null if obj is not of type Employee2 ;
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I'm already doing that, and that's what I want to avoid.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Ah, now I understand what you're trying to do.
In this case I don't think you get around some mapping mechanism and reflection, something like (defined in a XML file or whatever):
"Employee2" -> Property1 x Property2
But that still requires some knowledge about the types and properties being used.
Maybe you can use attributes and reflection to get a list of all the necessary properties to take into account when adding them to the listview. Something like this:
[ListViewProps("Propery1", "Not Applicable")]
class Employee1
{
}
[ListViewProps("Propery1", "Property2")]
class Employee2
{
}
And then doing some reflection magic to automatically get the values of the properties
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Not a answer to your exact question, but when I've needed to do this before I add a ToListViewItem() method in the class so each class can do it's thing seperately.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Sounds like a good solution, although it couples GUI logic with the business logic. I don't think an Employee object should know anything about a ListView
modified 12-Sep-18 21:01pm.
|
|
|
|