بدست آوردن آدرس IP از روی DNS HostName در C#
private void Button1_Click(object sender, EventArgs e)
{
    textBoxIP.Text = GetIP(GetHostName("http://mds-soft.persianblog.ir/post/100/"));
}

/// <summary>
/// Returns the Host name from a web address
/// </summary>
private string GetHostName(string WebAddress)
{
    string HostName = "";
    string OriginalUrl = WebAddress.Trim();
    Uri uri;

    if (!Uri.TryCreate(WebAddress, UriKind.Absolute, out uri))
        HostName = new UriBuilder(WebAddress).Host;
    else
        HostName = uri.Host;

    return HostName;
}

/// <summary>
/// Returns the IP of HostName
/// </summary>
private string GetIP(string HostName)
{
    IPAddress[] addresslist = Dns.GetHostAddresses(HostName);
    return addresslist[0].ToString();
} 



برچسب های این مطلب : #c و بریده کد و net
بدست آوردن نام host از یک آدرس اینترنتی در C#

شاید گاهی پیش بیاد که مایل باشید،آدرس host رو از یک URI یا URL استخراج کنید ، مثلا می خواهید آدرس persianblog.ir رو از آدرس زیر جدا کنید :
http://persianblog.ir/CreatePost.aspx?blogID=5752
برای این کار چند راه هست :

توسط عبارات منظم :

private string GetHostName(string WebAddress)
{
    string Pattern = @"//(\w.*?\w)/";
    Regex re = new Regex(Pattern, RegexOptions.IgnoreCase);
    string HostName = re.Match(WebAddress.Trim()).Groups[1].Value;
    return HostName;
} 

توسط Uri و UriBuilder :

private string GetHostName(string WebAddress)
{
    string HostName = "";
    string OriginalUrl = WebAddress.Trim();
    Uri uri;

    if (!Uri.TryCreate(WebAddress, UriKind.Absolute, out uri))
        HostName = new UriBuilder(WebAddress).Host;
    else
        HostName = uri.Host;

    return HostName;
} 



برچسب های این مطلب : #c و بریده کد و net
حل کاهش سرعت RapidShare

منبع




برچسب های این مطلب : ترفند و رپیدشیر و net
Windows Installer 4.5 Redistributable

اگر با نصب .Net Framework 3.5 SP1 مشکل داشتید ، از این لینک windows installer مربوط به سیستم عامل خودتون رو دانلود و نصب کنید.

مشکلتون حل میشه




برچسب های این مطلب : windows و net و #c و wpf