CodeKeep C# Feed Novembre 23rd, 2007
Description: This example shows how to initialize a web service when using forms authentication
Link:
http://www.codekeep.net/snippets/7e2513e7-7e51-427a-b414-257217861297.aspxprotected UserGroup ws_UserGroup
{
get
{
if (m_wsGroup == null)
{
Authentication auth = new Authentication();
auth.CookieContainer = new CookieContainer();
LoginResult result = auth.Login("username", "password");
if (result.ErrorCode == LoginErrorCode.NoError)
{
CookieCollection cookies = auth.CookieContainer.GetCookies(new Uri(auth.Url));
Cookie authCookie = cookies[result.CookieName];
m_wsGroup = new UserGroup();
m_wsGroup.CookieContainer = new CookieContainer();
m_wsGroup.CookieContainer.Add(authCookie);
m_wsGroup.Url = ConfigurationManager.AppSettings["ws_Group_URL"];
}
}
return m_wsGroup;
}
}
CodeKeep C# Feed Novembre 23rd, 2007
->
Description: Fragment to read a txt file
Link: http://www.codekeep.net/snippets/053843f4-204c-478d-a419-4088c0d3cfd4.aspx
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace LabelPrinter
{
class Program
{
static void Main(string[] args)
{
string file = @"C:\Documents and Settings\kaa8823\My Documents\Visual Studio 2005\Projects\Classes\Solution\LabelPrinter\LabelPrinter\Resources\Labeltest1.lbl";
string strLine = "";
StreamReader sr = new StreamReader(file);
while (!sr.EndOfStream)
{
strLine = sr.ReadLine().ToString();
Console.WriteLine(strLine);
}
sr.Close();
Console.ReadLine();
}
}
}
CodeKeep C# Feed Novembre 23rd, 2007
Description: Fragment to read a txt file
Link: http://www.codekeep.net/snippets/053843f4-204c-478d-a419-4088c0d3cfd4.aspx
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace LabelPrinter
{
class Program
{
static void Main(string[] args)
{
string file = @"C:\Documents and Settings\kaa8823\My Documents\Visual Studio 2005\Projects\Classes\Solution\LabelPrinter\LabelPrinter\Resources\Labeltest1.lbl";
string strLine = "";
StreamReader sr = new StreamReader(file);
while (!sr.EndOfStream)
{
strLine = sr.ReadLine().ToString();
Console.WriteLine(strLine);
}
sr.Close();
Console.ReadLine();
}
}
}
CodeKeep C# Feed Novembre 23rd, 2007
Description: Fragment to read a txt file
Link:
http://www.codekeep.net/snippets/053843f4-204c-478d-a419-4088c0d3cfd4.aspxusing System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace LabelPrinter
{
class Program
{
static void Main(string[] args)
{
string file = @"C:\Documents and Settings\kaa8823\My Documents\Visual Studio 2005\Projects\Classes\Solution\LabelPrinter\LabelPrinter\Resources\Labeltest1.lbl";
string strLine = "";
StreamReader sr = new StreamReader(file);
while (!sr.EndOfStream)
{
strLine = sr.ReadLine().ToString();
Console.WriteLine(strLine);
}
sr.Close();
Console.ReadLine();
}
}
}