|
Follow the Following code. Pass the number to Download function in string format. You ll get the answer. Worked for me.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace RequestURL
{
class Program
{
static void Main(string[] args)
{
string response = Download("0");
Console.WriteLine(response);
Console.ReadLine();
}
private static string Download(string number)
{
string text = "http://utptt-ex.petronas.com.my/Reporting/Individual?identifier=" + number + "&B1=View+Timetable&objectclass=students&idtype=id&width=100&periods=1-30";
string responseFromServer = "";
try
{
WebRequest request = WebRequest.Create(text);
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
responseFromServer = reader.ReadToEnd();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return responseFromServer;
}
}
}
|
|
|
|
|
Thank you for the codes, can I save the response from the web into a file?
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace RequestURL
{
class Program
{
static void Main(string[] args)
{
string response = Download("0");
Console.WriteLine(response);
Console.ReadLine();
}
private static string Download(string number)
{
string text = "http://utptt-ex.petronas.com.my/Reporting/Individual?identifier=" + number + "&B1=View+Timetable&objectclass=students&idtype=id&width=100&periods=1-30";
string responseFromServer = "";
try
{
WebRequest request = WebRequest.Create(text);
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream, Encoding.ASCII);
responseFromServer = reader.ReadToEnd();
StreamWriter writer = new StreamWriter("C:\\a.txt");
writer.Write(responseFromServer);
writer.Close();
reader.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return responseFromServer;
}
}
}
|
|
|
|
|
my english is pool. i don't know clearly.
for example:
public static string Post(string action, string parmString)
{
try
{
//Encode
Encoding myEncoding = Encoding.GetEncoding("GB2312");
//get URL
Uri myUri = new Uri(action);
//byte[]
byte[] paramBytes = myEncoding.GetBytes(parmString);
//new a webrequest
WebRequest myWebRequest = WebRequest .Create(myUri);
//set ContentType
myWebRequest.ContentType = "application/x-www-form-urlencoded";
//set Method
myWebRequest.Method = EnumWebMethod.POST.ToString();
//init request, get back stream
using (Stream requestStream = myWebRequest.GetRequestStream())
{
//send data
requestStream.Write(paramBytes, 0, paramBytes.Length);
}
//send request, get WebResponse object
WebResponse myWebResponse = myWebRequest.GetResponse();
//
using (StreamReader myStreamReader = new StreamReader(myWebResponse.GetResponseStream(), myEncoding))
{
return myStreamReader.ReadToEnd();
}
}
catch
{
return "request error!";
}
}
i hope i can help you.
modified on Wednesday, September 23, 2009 9:41 PM
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:04pm.
|
|
|
|
|
HI
I am developing a .NET MyLib.dll to be exposed via COM to Excel.
In It there is a class called MyDotNetClass ( ComVisible is set to ture
and I have GUID attributer )
When I pass a Range to my AnyMethod and I want to get the FormulaR1C1Local
everything is thine.
When I want to call other method other than this ( including the getValue to get
the real valu conatined by the cells in that range, not its formula )
I have a lot of exception most of the same time.
Can you help me with that?
I already have a reference to Microsoft.Office.Interop.Excel library V12.0
for Excel 2007.
Thanks
Mn
<br />
class MyDotNetClass<br />
{<br />
String AnyMethod( Microsoft.Office.Interop.Excel.Range aRange )<br />
{<br />
object[,] formula = (object[,])aRange.FormulaR1C1;<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
'VB CODE<br />
Function MyFoo( aRange As Range) As String<br />
Dim myLibObj As New MyLib<br />
MyFoo = myLibObj.AnyMethod( aRange )<br />
End Function<br />
|
|
|
|
|
Hi All,
I am creating one MDI application using C# in VS 2008. I attached the code below. I open one RTF file through the Open menu of the main form using Open dialog and loads the file in to the rich text box present in the child form. My problem is before loading the file in to the child form, the current directory points to the Debug folder of the application, but after loading the file in to the child form the current directory changes to the file directory which I opened in the child form.
For example,
before loading the file, my current directory is : "C:\Sample\Debug"
after loading the file, it changes to : "C:\ArchiveFiles"
because i opened a file from the "C:\ArchiveFiles" directory.
It is the intended behaviour of the MDI application. How do avoid changing the current directory? I want the current directoy should always point to the directory from where the EXE is running.
Is there any way to do this?
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
Form4 f4 = null;
public Form3()
{
InitializeComponent();
this.IsMdiContainer = true;
f4 = new Form4();
f4.MdiParent = this;
f4.Show();
string ctDir = System.Environment.CurrentDirectory;
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
if (DialogResult.OK == openFileDialog1.ShowDialog())
{
f4.OpenFile(openFileDialog1.FileName, this);
}
string ctDir = System.Environment.CurrentDirectory;
MessageBox.Show(ctDir);
}
}
}
public partial class Form4 : Form
{
public Form4()
{
InitializeComponent();
}
public void OpenFile(string filename,Form parent)
{
richTextBox1.LoadFile(filename);
}
}
Thanks in advance,
Mutpan
|
|
|
|
|
Set the directory before showing the dialog.
mutpan wrote: Form4 f4 = null;
You're joking, right ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: mutpan wrote:
Form4 f4 = null;
You're joking, right ?
Good point!
|
|
|
|
|
i don't know why you want to get current Directory.
so you can try these.
1) you can use:
System.IO.Directory.GetCurrentDirectory();
AppDomain.CurrentDomain.BaseDirectory;
Application.StartupPath
AppDomain.CurrentDomain.SetupInformation.ApplicationBase
Application.ExecutablePath
and so on.
2)
you can save the CurrentDirectory Path to a string at the first time you get it .
and send to the other form when you open it.
modified on Wednesday, September 23, 2009 9:45 PM
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:05pm.
|
|
|
|
|
hello
i am using toolstripComboBox.i want to access all the System colour paterns Along with there name how can i do this
i achive this on Simple combo on the form but for toolstripcombo it will not work
|
|
|
|
|
For anyone to be able to help you, we need to know what 'it will not work' means.
Some code (not too much, and properly formatted, use PRE tags) with an indication of which part fails, any error messages etc.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hello
if i am using simple combo box on the form the Draw item event appear and i use code on this event is
private void cmbboxClr_DrawItem(object sender, DrawItemEventArgs e)
{
Graphics g = e.Graphics;
Rectangle rect = e.Bounds;
if (e.Index >= 0)
{
string n = ((ComboBox)sender).Items[e.Index].ToString();
Font f = new Font("Arial", 9, FontStyle.Regular);
Color c = Color.FromName(n);
Brush b = new SolidBrush(c);
g.DrawString(n, f, Brushes.Black, rect.X, rect.Top);
g.FillRectangle(b, rect.X + 110, rect.Y + 5, rect.Width - 10, rect.Height - 10);
}
}
-----------------------------
and at form load event i use code
Type colorType = typeof(System.Drawing.Color);
PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
foreach (PropertyInfo c in propInfoList)
{
this.cmbboxClr.Items.Add(c.Name);
}
-------------------------------
and at select index change i use the code
private void cmbboxClr_SelectedIndexChanged(object sender, EventArgs e)
{
string color = this.cmbboxClr.SelectedItem.ToString();
this.panel1.BackColor = Color.FromName(color);
}
this will do but when i use toolstripcombo i'm not getting event Draw Item how can i achive the same thing using toolstripcombo my main problem is to access system colour patern along with name to change font or background colour
|
|
|
|
|
AFAIK the ToolStripComboBox does not have OwnerDraw capability. In fact most of the ToolStrip versions of controls are 'crippled' to some extend.
You might be able to save yourself a little processing and therefore make it a little faster by modifying your load event handler.
You could do something like:
foreach (string colorName in Enum.GetNames(typeof(KnownColor)))
{
this.cmbboxClr.Items.Add(colorName);
}
in fact you can even shorten that to either of:
this.cmbboxClr.Items.AddRange(Enum.GetNames(typeof(KnownColor)));
this.cbbboxClr.DataSource = Enum.GetNames(typeof(KnownColor)));
I have not done any time comparisons for these suggestions, and so cannot say which, if any, is faster than your current code.
As far as the ToolStripComboBox problem is concerned, it has occurred to me that, you might (again I have not tested it) put a standard ComboBox on the ToolStrip . Take a look at this[^] for further details.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
why not paste your codes?
try to get system colour paterns , bind to the toolstripComboBox;
or "toolstripComboBox.items.add()" one by one;
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 22:04pm.
|
|
|
|
|
hello
i give the code on 13th sep 09 but it is for normal combo draw item event on toolstripcombo there is not any draw item event how i achive it on toolstripcombo
|
|
|
|
|
I successfully execut SSIS package from C#.net
But when i tried that using windows service then SSIS package is not
execute.
How i can execute ssis package which is stored as file using windows service.
|
|
|
|
|
Follow this article: [^]
Make sure that the service run at 32 bit runtime if you use JET or ACE OLEDB connections. As they do not work on 64 bit run time.
|
|
|
|
|
I have put windows media player in a form, and was wondering if there is any way to see the bytes as they are being streamed to the viewer, so that I can manipulate them. I guess this would be like a buffering area where I can check the bytes and then play them.
Thanks
|
|
|
|
|
Didn't you ask this the other day ? I believe you can write what is called a 'pin' which gets inserted into the directX player sequence. If you can do this using WMP, I am not sure. But, that would be the only way to access the data as the player shows it, to have a flow of data in synch with the player.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks again for you response, I did ask this the other day. I have found that typically the problem is that in forums, if you get one reply then people move on and look for ones that have no responses. Sorry though, I'll try to refrain from double posts here. I'll give the pin thing a try, thank you.
Fox
|
|
|
|
|
I have a app which places a watermark (text) on an image and saves this back to a file.
What I would like to do is lighten a rectangle area behind the text so the text is clearer.
Can anyone point me to articles which would show how to lighten an area. I found many which show how to lighten/darken the image (bitmap) but noe for an area.
|
|
|
|
|
My image processing articles show you how to do that, you'd just have to change the code to only iterate over the pixels you want to lighten
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
1) you can lighten text , so the text is clearer.
2) you can make two pictures (one is lighten, the other is darken)
when mouse over the places , just change the pictures.
3) of course, you can draw a picture, by different way.(Pixel Zoom, different background color.....)
modified 27-May-14 5:28am.
|
|
|
|
|
Hello
I've a strange behaviour
If I add a ToolStripCombo in a toolstripmenu; I can bind that combo to a datatable and all is ok
BUT if I add a toolstripcombo in a second level (under a drop down button for example) the combo bided to the same datasource remain empty
What I'm doing wrong in such case ?
Thank for any help
|
|
|
|
|
why do you want to bind the datasource,
consider to use 'for loop' to add datas one by one.
modified 27-May-14 5:28am.
|
|
|
|