|
Hello
I have a string (string j;) inside the Program.cs file and when my application runs and Form1 is visible, I want to get the value of j from Program.cs file on the Form1_Shown event. Does anybody know how I would go about retrieving this value? Any help would be appreciated
Thank you.
Regards,
Jason Pezzimenti.
Knock knock.....
|
|
|
|
|
you can add a string parameter to the constructor of the form, and send it via that.
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
I’ll soon enter a project where I’m going to create an “Mail Report Generator”. In our SQL Server database we have a lot of information connected to users to the system.
Now I’m looking for different techniques to create these reports. The demands are that the email that is going to be sent should have an attached PDF-file which should contain tables, charts, and different types of diagram.
I’ve been thinking of Microsoft Reporting Services as a solution for generating PDFs. Can that be a good way of doing it?
All suggestions are welcomed!!
_____________________________
...and justice for all
|
|
|
|
|
Reporting Services would be really good..As far as I know, it's not only PDF but it also supports other formats like Excel, Images etc. I used it long back to create reports which users used to save their reports in different. If you are interested for sending automated mails, then you should definitely look into the APIs availble for generating PDFs.
Anyway,I can suggest you to see few more availble reporting tools also for your comparison. Checkout once DevExpreshttp://www.devexpress.com/Products/NET/Reporting/[^]s Xtrareports.
Let me know if you need any further details.
|
|
|
|
|
Hi All
Does anyone have an answer to this? im using C# Visual studio 2008?
So far I was thinking just loop through the first root folder, compare the length of the first file with the rest, and if the first files length is smaller then swap the bigger one with it, so at the end all the biggest files will be at the top..
DirectoryInfo dir = new DirectoryInfo(@"C:\");
foreach (FileInfo file in dir.GetFiles())
{
Console.WriteLine(file.Name);
foreach (FileInfo file2 in dir.GetFiles())
{
if (file.Length < file2.Length)
file2.MoveTo(file.ToString());
}
}
}
|
|
|
|
|
You can use LINQ to do this easily.
http://dotnetperls.com/sort-file-size
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
Luke Perrin wrote: file2.MoveTo(file.ToString());
do you really want to move files around?????
and do you think you can get a folder size without summing file sizes?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
You can use the code below, but it may need some performance improvements
List<FileInfo> fi = new List<FileInfo>();
ListBox l = new ListBox();
private void Form1_Load(object sender, EventArgs e)
{
}
private void GetSubFoldersAndFiles(string path)
{
foreach (string d in Directory.GetDirectories(path))
{
try
{
GetSubFoldersAndFiles(d);
}
catch (Exception)
{
}
}
foreach (string f in Directory.GetFiles(path))
{
fi.Add(new FileInfo(f));
}
}
private void Form1_Shown(object sender, EventArgs e)
{
l.Dock = DockStyle.Fill;
this.Controls.Add(l);
foreach (DriveInfo di in DriveInfo.GetDrives())
{
if (di.IsReady)
{
GetSubFoldersAndFiles(di.RootDirectory.FullName);
}
}
var a = (from s in fi orderby s.Length descending select s);
l.DataSource = a.ToList();
}
|
|
|
|
|
Hello,
How we can convert a PCL to PDF using C#, please help me to esolve this problem, thank you verry mutch.
|
|
|
|
|
C# does not have any existing API for this.
You may look at google [^]and try out of any thrid party or open source library for this.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
i want to sync my calendar application with microsoft outlook calendar. I want to share this data through XML. i want to implement 2 way sync. Does any one have any idea of approach which i can follow ??? I am facing problem while comparing my application data with outlook data while merging. plz help
|
|
|
|
|
I have been working on this issue for a few days now and I am growing tired and desperate
I have made this application which sends a screenshot (Image type) to another PC. All works well on most PCs except some very few of them. Those that do not work complain of a Binary stream '0' does not contain a valid BinaryHeader.
The code is exactly the same on the working / non-working PCs. I have also attempted to run the program locally on the PCs not working, and the exact problem occurs.
The Algorithm is as follows:
- Screenshot is taken (returned as Image)
- Size of the Image is sent (to prepare a byte[] for the receiving end)
- Image is converted into a MemoryStream from BinaryFormatter.Serialize
- MemoryStream.ToArray() gets byte[] which is written on a NetworkStream
- Receiving end receives the length of the object and prepares a byte[] with that length
- Receiving end reads the data on a byte[]
- Byte[] is Deserialized to object <- Exception occurs
I have checked the first 50 bytes being sent and received and they are exactly identical!!
It is true that the first byte is a 0 but this works with no problems at all on other systems
Why is this happening? How can I avoid this? Maybe using UnsafeDeserialize or something completely different?!
Any help is sooo greatly appreciated!!
|
|
|
|
|
Hi,
I don't know what problem you are having. One possibility is the (de)serializer is having an out-of-memory problem due to fragmentation in the large-object-heap.
Why do you need serialization at all? Couldn't you use Bitmap.Save(NetworkStream) and new Bitmap(NetworkStream)? I don't like your scheme requiring a potentially large array that much.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
i m doin device application
the problem is wih socket
my code was
clientsocket = new TcpClient(ip,2000);
clientsocket.ReceiveTimeout=10000;
this code gives an exception "option is not supported or something like that"
but this workd fine in windows application
so i wrote
clientsocket = new TcpClient(ip,2000);
this line raises exception
i m receiving exception
"An operation was attempted on something that is not a socket" after sometime or after a sequence of clicks
i think the problem is with socket timeout
if so how can i increase the socket time out
can any one help
This code was posted by me...
|
|
|
|
|
Hi,
I suggest you read the remarks in the MSDN document.[^] which is always a good thing to do (1) before using something and (2) when having problems.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Out email provider has SMTP authentication set to require "Log on to incoming mail server before sending"
In outlook, I configure this option in the Outgoing Server Settings. Its easy.
However, I can find no way of doing this programatically with System.Net.Mail. Or at least no config settings that give a clue.
If I set outlook to use the same credentials as the incoming server then it fails. i.e. I can't just provide the username and password as it won't work.
Any clues?
regards
James
|
|
|
|
|
you can do it like this:
<system.net>
<mailSettings>
<smtp from="validname@mydomain.com">
<network host="mail.mydomain.com" password="" userName="validname@mydomain.com"/>
</smtp>
</mailSettings>
</system.net>
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
public class TXDataGridViewNumericColumn : DataGridViewColumn
{
public TXDataGridViewNumericColumn() : base(new TXNumericCell())
{
this.InputType = NumericType.Integer;
}
public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
if (value != null &&
!value.GetType().IsAssignableFrom(typeof(TXNumericCell)))
{
throw new InvalidCastException("Must be a CalendarCell");
}
base.CellTemplate = value;
}
}
private NumericType m_NumericType;
public enum NumericType
{
Decimal,
Integer,
PositiveDecimal,
NegativeDecimal,
PositiveInteger,
NegativeInteger
}
public NumericType InputType
{
get { return m_NumericType; }
set { m_NumericType = value; }
}
public ICollection testCollection
{
get
{
return Icollection;
}
set
{
Icollection = value;
}
}
private ICollection Icollection;
public override object Clone()
{
DataGridViewColumn col = (DataGridViewColumn)base.Clone();
col.CellTemplate = new TXNumericCell();
return col;
}
}
I define a column by inheritting the DataGridViewColumn, and add a property for this column, but in the design-mode when I change the value of this property , the value can not be saved, the codes as above. how to solve this issue? Thanks in advance!
|
|
|
|
|
you have already posted this question!!!!!
posting questions again does not mean you will get the answer quickly
and also try to search answers your self and id dont find it then post the question
|
|
|
|
|
Hi,
Can someone give me some straight example on how to view such an Office Document '.doc' in a Web Browser Control .
You're help is really appreciated .
Kind Regards,
Erson
|
|
|
|
|
Don't repost - it displays an ignorance of forum use
What the hell do you want if the link d@nish supplied is not an answer to your question.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The link d@nish sent you was probably the ONLY straight forward approach to doing what you want. I also was looking something like this and I have already implemented the feature with no issues. What's stopping you?
Regards,
Jason Pezzimenti.
|
|
|
|
|
Hi.
I need to calculate the difference between two date and time fields
I Am Try blow coding but give error
"String was not recognized as a valid DateTime"
InitializeComponent();
{
timer.Tick += new EventHandler(timer1_Tick);
timer.Interval = (1000) * (1);
timer.Enabled = true;
timer.Start();
}
private void Form1_Load(object sender, EventArgs e)
{
label7.Text = DateTime.Now.ToShortTimeString();
DateTime dt1 = DateTime.ParseExact(label6.Text, "hh:mm:ss", new DateTimeFormatInfo());
DateTime dt2 = DateTime.ParseExact(label7.Text, "hh:mm:ss", new DateTimeFormatInfo());
TimeSpan ts1 = dt1.Subtract(dt2);
textBox1.Text = ts1.ToString();
}
private void timer1_Tick(object sender, EventArgs e)
{
label6.Text = DateTime.Now.ToShortTimeString();
label6.Text = DateTime.Now.ToString("hh:mm:ss");
}
|
|
|
|
|
On my PC, DateTime.Now.ToShortTimeString() shows the date as 11:42 AM. If you have something similar, it will fail when you parse it as hh:mm:ss.
What happens when you debug it and watch the values? Do the two labels really show the date in hh:mm:ss format? Either change the format string, or use DateTime.Now when you do the subtraction.
Cheers,
Vikram. (Proud to have finally cracked a CCC!) Recent activities:
TV series: Friends, season 10
Books: Fooled by Randomness, by Nassim Nicholas Taleb. Carpe Diem.
|
|
|
|
|
Values in label6 is like 11:18:17 and Values of label7 is 11:18:17, the value of label7 is constant.
|
|
|
|