|
Nope, you're gonna have to handle the paint event yourself.
"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
|
|
|
|
|
Done now, and if anyone whats to know, here is what i did.
Created userControl that inherits from ToolStrip
Then overrided the painting with the following code - very simple really;
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.FillRectangle(new SolidBrush(this.Parent.BackColor), 0, this.Height - 2, this.Width + 1, this.Height + 1);
}
Note: the 1 and 2 constant values used where the first I tried and worked so not checked to see if 0 and 1 would have worked
|
|
|
|
|
hi all
plz help me.............
i want to access file which is present on another server..........
.
.
e.g suppose i want to get all file information using "fileinfo"
if file filename.txt is present on http://www.abcd.com/file/filename.txt
and my application is on http://www.zyx.com/homepage.aspx
.
and my code is present in homepage.aspx
.
and i want to retrieve "filename.txt" . lastaccesstime etc..
.
then what should i used to access that file..........
i used server.mappath(.....) but it is used for my application.......
so anyone please suggest me that how to access that file...
using url string........
waiting for reply...........
...........................
|
|
|
|
|
you could FTP to the server, download the file then do whatever you want with it.
course you will need FTP access privilages.
If this is an option, do a search for 'C# FTP' or something. Its actually not too much code to download a file.
|
|
|
|
|
You can't do this using anything in the System.Io namespace if the file is behind a web server. Those classes will not work over HTTP.
The information you want would have to be exposed by the web server, probably using a web service, or, if the site was poorly run, exposed by directory browsing being turned on in the web server.
|
|
|
|
|
i tried it but its not working......
.
.
my problem is ........
suppose im having two servers...
.
and im using.
.
http://www.oneserver.com/files
and http://www.sendserver.com/files
.
where files is a directory containg list of files.
.
.
and i hav to maintain the list of changed files with creation time, last access times, new files uploaded to that location etc...
.
.
so how to map that paths.
.
my applciation is running on
http://www.oneserver.com/myapplication.aspx
i tried it using server.mappath("files/filename.txt");
it is working for oneserver only.......
but through that application means http://www.oneserver.com/myapplication.aspx
i want to access http://www.secondserver.com/files..
and my code is thr in http://www.oneserver.com/myapplication.aspx.
.
to how to access secondserver.com/files through that code..
.
i tried it several ways but still not getting how to do it.
.
.
please help me.
.
thanks in advanced...
...........................
|
|
|
|
|
Of it's not working! I just got done tell you that it's not going to work.
You can't map a drive letter to an http:// path. Webservers doesn't support what you want to do. You have to use some other server on those boxes to get the information you want, such a FTP.
|
|
|
|
|
but will u please tell me how to achieve it
.
.
...........................
|
|
|
|
|
I already did. You have to use a different server, like FTP, on those site in which you want to do this. You can NOT accomplish this at all using a web server (Http). If you don't control these web sites, there's nothing you can do about it.
|
|
|
|
|
dear, mr. dave
.
.
im also having another problem in accessing file from server.
.
e.g. if file is stored on c:\inetpub\wwwroot\myfiles\filename.txt
and im accessing it using
FileStream fs = new FileStream(@"http://localhost/myfiles/filename.txt", FileMode.Open, FileAccess.Read);
then file in not being accessed.
.
will u plz tell me how to achieve this.
.
actually im a newbie to c#.net
thanks in advanced......
.
.
...........................
|
|
|
|
|
For the last time. You can NOT user anything in the System.Io namespace on files and folders that begin with "http://". You cannot open files through a web server.
You have to use a path the start with a drive letter or UNC path. Using a URL will not work. If you're trying to access a file from the browser side, and the file is on the server, you can't.
sushilbondre wrote: actually im a newbie to c#.net
...and to networking and web technologies too.
|
|
|
|
|
I'm trying to, as the subject line suggests, retrieve a single row from a table with the table's primary key, then edit the row's columns before updating the row to save my changes.
Am I way off here? I'm not sure how to update an existing row.
EdsDBDataSet.VideoRow videoRow = edsDBDataSet.Video.FindByVideo_ID(int.Parse(txtID1.Text));
videoRow.Video_Description = txtDescription.Text;
|
|
|
|
|
Hi,
For my web application, I am creating a text file that is stored in a shared network folder. This file needs to have a generic name (ie Text.txt) and each subsequent file will be named with incrementing numbers(Text2.txt then Text3.txt, etc). How do I create the function that will open the target folder, look to see what the last created file was and then create the new file with the appropriate number added to the filename? I also need to pass the created file name to my second webform where it will be monitored.
I want to execute the creation of the text file on a button click.
Thanks in advance for any help given!
|
|
|
|
|
I'd start with checking if the folder exists, if so I would count the number of txt files in there (frankly I would use a different extension, simply because other people can drop .txt files in there) and I would count how many exist. Then I would take that number, add a 1 to it and create my "Text" & i.ToString & ".ext" and close it up.
I use i to count.
Enjoy
|
|
|
|
|
Dont use the count, cuz if a file is deleted, the 'count + 1' will result in a file name already in use.
Get the fileinfos for the files, then find which is the most recent, then get the number from that and then increment
|
|
|
|
|
Specification didn't take into account deletion of files
|
|
|
|
|
fair enough, was just a heads up
|
|
|
|
|
Store the last number used in a database or the config file or something, that will allow you to manage it.
|
|
|
|
|
You could use recursion.
steps:
Check if file text.txt exist
--> if so ad a number to the name and redo check (exacute untill check is false (increase the number everytime)
--> if not create/save the file with the current name
If you want I have some vb.net code that does this somewhere but can't look it up at the moment since I'm not at the office.
|
|
|
|
|
1) Get all filenames in a directory
2) Sort the list of names using a custom comparer to put your files ("TextNN.txt") with the highest number first
3) Take the first file after the sort and extract the number
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
if the number embedded in the filename uses a fixed format with leading zeroes the alphabetical order is the numeric order too, so no special comparer would be needed.
|
|
|
|
|
Luc Pattyn wrote: if the number embedded in the filename uses a fixed format with leading zeroes the alphabetical order is the numeric order too, so no special comparer would be needed.
True, but this requires two things:
1) the number has leading zeros
2) the "TextNN" files are the only files in this folder, no other files like "AAA" and "ZZZ" which would put the "TextNN" files to the middle of the list.
Duh, forgot you can use a filter pattern to get the filenames
With a custom comparer you're on the safe side
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you all for your posts. It's been helpful. I'm still a little stuck, but I have the general idea.
The files may get deleted, so I will need to take that into account. Also, I'm not using any database and for this application wont be using one.
This is what I have so far. Please let me know if there are better methods:
public void filecount(string file)
{
int x;
int y;
string file;
int filepaths = Directory.GetFiles(@"C:\Desktop\Request", "*txt").Length;
x = filepaths +1;
StreamWriter sw;
sw = File.CreateText(@"C:\Desktop\Request\Text" +y +".txt");
file = Path.GetFileName(@"C:\Desktop\Request\Text" +y +".txt").ToString;
sw.Close();
return file;
}
public void btn_Click(object sender, EventArgs e)
{
filecount(file);
}
Thanks again for helping a newbie out!
|
|
|
|
|
That's how I'd do it:
string[] logfiles = Directory.GetFiles(@"../Files/", @"Text*.txt");
Array.Sort(logfiles, CompareFileNumbers);
int highestNumber = int.Parse(Regex.Match(logfiles[0], @"(\d+)").Value);
with the custom comparer being:
public static int CompareFileNumbers(string fileA, string fileB)
{
Regex regexNumber = new Regex(@"(\d+)");
int fileNumberA = int.Parse(regexNumber.Match(fileA).Value);
int fileNumberB = int.Parse(regexNumber.Match(fileB).Value);
return -fileNumberA.CompareTo(fileNumberB);
}
Tested and it works. You need to add error checking though in case the filenames don't have numbers (the regexes will fail) and other cases.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
This won't work - in fact I don't think it will compile.
1 The return type is void but the function tries to return a string.
2 The parameter name (file) conflicts with the local variable also called file.
3 The value of y is not set but is used to construct the file name.
Couple of other comments.
1 Why use the x and y variables when you have filepaths. You could just set it to Directory.GetFiles(@"C:\Desktop\Request", "*txt").Length + 1. Then use it instead of x or y.
2 This approach does not deal with deleted files. Suppose there are three files originally (text1.txt, text2.txt, text3.txt). Then text1.txt is deleted. What will the file count be?
3 The function is named filecount but it actually tries to return the next filename.
4 Read some of the suggestions carefully - there's good stuff in them that should solve the problem.
Regards
David R
|
|
|
|