|
Hi,
i want to copy a line from any text file and paste it to another text file.
let me know how to do that?
regards
pankaj kumar
|
|
|
|
|
Which bit are you stuck on ? You can't insert text into a file, you need to read it, insert it in memory, and overwrite the existing file.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
basically i need to check a checkbox on an access database to therefore block the user from using that account. my code is wrong(below) plus the catch exception is brining up this message "No value given for one or more required parametres"
i think this line of code could be the problem because i keep on getting warningsm on it :- If dr.Read() Then 'if the entry is correct (readable)
can anyone recterfy my code please?
Imports System.Data.OleDb
Public Class Block
Public conn As OleDbConnection
Public comm As OleDbCommand
Public dr As OleDbDataReader
Public da As OleDbDataAdapter
Dim icount As Integer
Private Sub Btnblock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBlock.Click
'when the logon button is pressed
Dim ManagerLogin As String
'declares the variable
Try
conn = New OleDbConnection 'establishes that conn is a new connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\PCBank.mdb" 'the name of the connection (name of the database on the end)
conn.Open() 'opens the connection
comm = New OleDbCommand 'establishes that comm is a new command
comm.Connection = conn 'the connection for the command is the connection specified
comm.CommandType = CommandType.Text 'the commands are in text
ManagerLogin = "SELECT DISTINCT Password FROM Accounts WHERE ManagerID='" & Me.tbID.Text & "' "
'the variables value is an SQL command, selects value that is equal to the id AND password.
''MessageBox.Show(ManagerLogin) 'shows the sql command (only needed for testing)
comm.CommandText = ManagerLogin 'the variable is declared as a command
dr = comm.ExecuteReader 'gives the variable a value
conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=PCBank.mdb")
conn.Open()
comm = New OleDbCommand("insert into Accounts(Blocked) values('" & (chBlock.CheckState) & "')", conn)
icount = comm.ExecuteNonQuery()
MsgBox("record inserted")
chBlock.Checked = False
Catch ex As Exception
MsgBox(ex.Message)
If dr.Read() Then 'if the entry is correct (readable)
Me.Close()
Form2.Show() 'show the index varibale (form)
'close the current form
Else 'if the entry is incorrect
MessageBox.Show("Invalid ID, please try again") 'displays error message
tbID.Clear() 'clears the managerid
End If 'end if
End Try
conn.Close()
End Sub
End Class
|
|
|
|
|
I'm not sure, but it looks like you're inserting a new record into a table called Accounts. Shouldn't this be an UPDATE statement that changes as field in the record in question?
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
We had developed a project using asp.net with vb script. Dash Board solutions. it is to update the data in our department and to keep track of date and work. It had different logins for each user and different kind of permission for differet kind user viz manager, leader, associate. A brief description is given,
Introduction:
The project is a complete project monitoring and scheduling system that coordinates the activities of our offshore hydraulics research center located at Bangalore. As many as 50 users may be using this system at any given time. The objective was to develop a secure, single window, loading and scheduling system, which has the following features.
Efficiently coordinate a hierarchy of team members comprising of Administrators, Managers, Leaders and Associates.
Simplify the loading and scheduling process, together with effectively managing task types and material specifications for the resources used in the project.
Streamline workflow and inculcate effective delegation of responsibilities within the team hierarchy.
All or individual stages of the project may be assigned/resigned to various team leads in various time frames. Therefore a means to tracking document history was incorporated into the system.
A messaging system keeps the managers and leads well informed about the current status of the project, thus minimizing possible stumbling blocks and increasing the clarity of the big picture.
As progress is made on each project, associate/ team leader feedback is used to calculate plausible cycle times and scheduling sequences that would be optimum for current and future projects.
All of these steps were instrumental in ensuring maximum productivity, smoother transition from the analysis to the development stage, which in turn ensured a faster time-to-market and ROI for our offshore research centers.
Tools and Technologies : VB.NET, ASP.NET, SQL Server, Crystal Report
Domain : Project Monitoring
The products to which project will be taken are broadly divided into two categories viz.,
1. Cylinders
2. Truck hydraulic
The user of this project will be one among the following.
1. Administrator
2. Manager
3. Project leader
4. Project associate
5. Marketing Executive
the project has developed in .net 2002. Now we have installed .net 2005. The users wanted some changes and i did those changes and copied those files from my local system to server. but when we go for url (http:\\wielweb\dbs) i am getting the following error. what could be the reason for the error?
Server Error in '/dbs' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The 'CodeFile' attribute is not supported by the 'page' directive.
Source Error:
Line 1: <%@ Page Language="vb" AutoEventWireup="false" Inherits="Dash_Board.WebForm1" CodeFile="Login.aspx.vb" %>
Line 2:
Line 3:
Source File: D:\Deljo\DBS\Login.aspx Line: 1
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET Version:1.1.4322.2300
Chaitra N
|
|
|
|
|
I could be wrong but I believe the CodeFile attribute is for .Net 2.0 not 1.1
" In the next millennium there are two kinds of business, those on the Internet and those out of business"
Bill Gates
"Be nice to nerds. Chances are you'll end up working for one."
Bill Gates
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
If it is so, what is the change i have to make, Here is the code of login.aspx.vb file,
<%@ Page Language="vb" AutoEventWireup="false" Inherits="Dash_Board.WebForm1" CodeFile="Login.aspx.vb" %>
<title>Dash Board Solution
<asp:label id="Label1" runat="server" text="Login Name :" forecolor="SaddleBrown" width="136px" font-names="Vrinda" font-size="Large">Login Name :
|
<asp:textbox id="txtlogin" runat="server" forecolor="SaddleBrown" width="134">
| <asp:label id="lblmsg" runat="server" forecolor="Red" text="Incorrect Login !" visible="False">
|
<asp:label id="Label2" runat="server" text="Password :" forecolor="SaddleBrown" width="114px" font-names="Vrinda" font-size="Large">Password : | <asp:textbox id="txtpassword" runat="server" forecolor="SaddleBrown" width="134" textmode="Password"> | | <asp:button id="btnlogin" runat="server" text="LOGIN" forecolor="SaddleBrown" width="76px">
|
| |
Chaitra N
|
|
|
|
|
If it is so, what changes i need to do to make it work properly. Here is the code of "login.aspx" file
<%@ Page Language="vb" AutoEventWireup="false" Inherits="Dash_Board.WebForm1" CodeFile="Login.aspx.vb" %>
<title>Dash Board Solution
<asp:label id="Label1" runat="server" text="Login Name :" forecolor="SaddleBrown" width="136px" font-names="Vrinda" font-size="Large">Login Name : |
<asp:textbox id="txtlogin" runat="server" forecolor="SaddleBrown" width="134">
| <asp:label id="lblmsg" runat="server" forecolor="Red" text="Incorrect Login !" visible="False"> |
<asp:label id="Label2" runat="server" text="Password :" forecolor="SaddleBrown" width="114px" font-names="Vrinda" font-size="Large">Password : | <asp:textbox id="txtpassword" runat="server" forecolor="SaddleBrown" width="134" textmode="Password"> | | <asp:button id="btnlogin" runat="server" text="LOGIN" forecolor="SaddleBrown" width="76px">
|
| |
Chaitra N
|
|
|
|
|
I created a VB.Net library which I hope to use in VB6.0 I issues this command regasm test.dll /tlb: test.tlb but unfortunatly I could not reference any of the public properties. Plz I need help for urgent solution.
What worths doing should be done well
|
|
|
|
|
Did you create a COM dll in VB.NET, and if not, how did you hope for this to work ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
how do i find a record in a multi column table data view in vb.net and how can i move in that view....like move next, move previous etc. as it could be done in the recordset of vb
|
|
|
|
|
Hi Anz,
Check it
http://www.codeproject.com/vb/net/SQLEditor.asp[^]
It can Help u
See in article
'If the table contains a primary key, use that to find the record.
For i As Integer = dca.GetLowerBound(0) To dca.GetUpperBound(0)
dv.RowFilter = "COLUMN_NAME = '" & dca(i).ColumnName & "'"
sSQLDataType = dv(0)("TYPE_NAME").ToString()
If sSQLDataType.Equals("text") Or _
sSQLDataType.Equals("ntext") Or _
sSQLDataType.Equals("image") Then
sTmp = "[" + dca(i).ColumnName + "] LIKE @" + _
RemoveIllegalChars(dca(i).ColumnName, _
m_RemoveChars)
Else
sTmp = "[" + dca(i).ColumnName + "] = @" + _
RemoveIllegalChars(dca(i).ColumnName, _
m_RemoveChars)
End If
If dca.GetLength(0) > 1 Then
sSQL = sSQL + "(" + sTmp + ")"
Else
sSQL = sSQL + sTmp
End If
If i <> dca.GetUpperBound(0) Then sSQL = sSQL + " AND "
Next
Pankaj Jain
|
|
|
|
|
i want to show tiff in image edit and also zoom and scroll the image
sathish
|
|
|
|
|
Are you going to write this "image edit control" or are you going to use a third party control?
The .NET Framework doesn't come with a packaged control that does this.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
(if possible) i want to use image edit control (else) please tell me which third party control is very useful
|
|
|
|
|
Keep this in the forums. I don't answer emails sent directly to me.
There is no "image edit control" that comes with the .NET Framework, and I've never had to use a third party control. I would suggest Googling for ".NET Image Editing Control" and see what comes up.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
i have a program that show the size of programs but i want something to add to the program but i have no idea so if the program gives the access denied error it stops and i don't want that it stops and it does the next file how and where should i have to add these files.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace DirectorySize
{
public partial class Form1 : Form
{
delegate void SetStatusbarCallback(string text);
private DataTable m_dirs = new DataTable();
private Dictionary m_dirsSize = new Dictionary();
#region Form
public Form1()
{
InitializeComponent();
}
private void Form1_Resize(object sender, EventArgs e)
{
if (Form1.ActiveForm != null)
{
grdDirectories.Width = (Form1.ActiveForm.Width / 2) - 4;
grdFiles.Width = (Form1.ActiveForm.Width / 2) - 4;
grdFiles.Left = (Form1.ActiveForm.Width / 2);
}
}
private void Form1_Load(object sender, EventArgs e)
{
this.Width = Properties.Settings.Default.ProgramWidth;
this.Height = Properties.Settings.Default.ProgramHeight;
if (Properties.Settings.Default.ProgramLeft > -100)
{
this.Left = Properties.Settings.Default.ProgramLeft;
this.Top = Properties.Settings.Default.ProgramTop;
}
txtFolder.Text = Properties.Settings.Default.Directory;
grdDirectories.Width = (this.Width / 2) - 4;
grdFiles.Width = (this.Width / 2) - 4;
grdFiles.Left = (this.Width / 2);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.ProgramWidth = this.Width;
Properties.Settings.Default.ProgramHeight = this.Height;
Properties.Settings.Default.ProgramLeft = this.Left;
Properties.Settings.Default.ProgramTop = this.Top;
Properties.Settings.Default.Save();
}
#endregion
#region Scan Directory
#region Buttons
private void btnScan_Click(object sender, EventArgs e)
{
if (!Directory.Exists(txtFolder.Text))
{
MessageBox.Show("The folder does not exist.");
txtFolder.Focus();
return;
}
Properties.Settings.Default.Directory = txtFolder.Text;
Properties.Settings.Default.Save();
btnCancel.Enabled = true;
btnScan.Enabled = false;
txtFolder.Enabled = false;
toolStripProgressBar1.Visible = true;
toolStripProgressBar1.Value = 0;
this.Cursor = Cursors.WaitCursor;
this.backgroundWorker1.RunWorkerAsync();
}
private void btnBrowse_Click(object sender, EventArgs e)
{
if (txtFolder.Text.Trim() != "")
folderBrowserDialog1.SelectedPath = txtFolder.Text.Trim();
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
txtFolder.Text = folderBrowserDialog1.SelectedPath;
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.btnCancel.Enabled = false;
this.backgroundWorker1.CancelAsync();
}
#endregion
///
/// Controls in Windows Forms are bound to a specific thread and are not thread safe.
/// Therefore, if you are calling a control's method from a different thread, you must
/// use one of the control's invoke methods to marshal the call to the proper thread.
///
///
private void SetStatusBar(string text)
{
if (this.statusStrip1.InvokeRequired)
{
SetStatusbarCallback d = new SetStatusbarCallback(SetStatusBar);
this.Invoke(d, new object[] { text });
}
else
{
this.toolStripStatusLabel1.Text = text;
}
}
///
/// The method that does all the work.
///
/// The directory to search from.
///
private bool LoopFolder(DirectoryInfo[] dis)
{
if (this.backgroundWorker1.CancellationPending)
return false;
foreach (DirectoryInfo di in dis)
{
if (this.backgroundWorker1.CancellationPending)
return false;
string fullname = di.FullName;
SetStatusBar(fullname);
double size = GetFilesSize(di);
DataRow dr = m_dirs.NewRow();
dr["Name"] = fullname;
dr["Size"] = size;
m_dirs.Rows.Add(dr);
m_dirsSize.Add(fullname, size);
// sum up the fullsize on all parents
DirectoryInfo parent = di.Parent;
while (parent != null && !this.backgroundWorker1.CancellationPending)
{
if (m_dirsSize.ContainsKey(parent.FullName))
{
m_dirsSize[parent.FullName] += size;
parent = parent.Parent;
}
else
break;
}
toolStripProgressBar1.PerformStep();
}
return true;
}
///
/// Gets the total size of all files in the directory.
///
///
///
private double GetFilesSize(DirectoryInfo di)
{
double size = 0.0;
long lSize = 0;
foreach (FileInfo fi in di.GetFiles())
lSize += fi.Length;
size = Convert.ToDouble(lSize) / 1024.0 / 1024.0; // size in MB
return size;
}
#region BackgroundWorker
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
// Do not access the form's BackgroundWorker reference directly.
// Instead, use the reference provided by the sender parameter.
BackgroundWorker bw = sender as BackgroundWorker;
// Extract the argument.
//string[] args = (string[])e.Argument;
m_dirs = new DataTable();
m_dirsSize.Clear();
m_dirs.Columns.Add("Name", typeof(string));
m_dirs.Columns.Add("Size", typeof(double));
m_dirs.Columns.Add("Fullsize", typeof(double));
// Start the time-consuming operation.
DirectoryInfo di = new DirectoryInfo(txtFolder.Text);
DirectoryInfo[] dis = di.GetDirectories("*", SearchOption.AllDirectories);
toolStripProgressBar1.Maximum = dis.Length;
e.Result = LoopFolder(dis);
// If the operation was canceled by the user,
// set the DoWorkEventArgs.Cancel property to true.
if (bw.CancellationPending)
{
e.Cancel = true;
}
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
btnCancel.Enabled = false;
btnScan.Enabled = true;
txtFolder.Enabled = true;
toolStripProgressBar1.Visible = false;
this.Cursor = Cursors.Default;
if (e.Cancelled)
{
// The user canceled the operation.
MessageBox.Show("Operation was canceled");
}
else if (e.Error != null)
{
// There was an error during the operation.
string msg = String.Format("An error occurred: {0}", e.Error.Message);
MessageBox.Show(msg);
}
else
{
foreach (DataRow dr in m_dirs.Rows)
{
dr["Size"] = Math.Round((double)dr["Size"], 2);
string fullname = (string)dr["Name"];
if (m_dirsSize.ContainsKey(fullname))
dr["Fullsize"] = Math.Round(m_dirsSize[fullname], 2);
}
m_dirs.DefaultView.Sort = "Size desc";
grdDirectories.DataSource = m_dirs;
toolStripStatusLabel1.Text = m_dirsSize.Count + " directories found.";
}
}
#endregion
#endregion
#region Show files
private void grdDirectories_SelectionChanged(object sender, EventArgs e)
{
if (grdDirectories.SelectedRows.Count == 1)
{
string directory = grdDirectories.SelectedRows[0].Cells[0].Value.ToString();
toolStripStatusLabel1.Text = directory;
DataTable tblFiles = new DataTable();
tblFiles.Columns.Add("Name", typeof(string));
tblFiles.Columns.Add("Size", typeof(double));
tblFiles.Columns.Add("LastAccessTime", typeof(DateTime));
tblFiles.Columns.Add("LastWriteTime", typeof(string));
tblFiles.Columns.Add("CreationTime", typeof(string));
tblFiles.Columns.Add("ReadOnly", typeof(bool)).ReadOnly = true;
tblFiles.Columns.Add("Ext", typeof(string));
DirectoryInfo di = new DirectoryInfo(directory);
foreach (FileInfo fi in di.GetFiles())
{
DataRow dr = tblFiles.NewRow();
dr["Name"] = fi.Name;
dr["LastAccessTime"] = fi.LastAccessTime;
dr["Size"] = Math.Round(fi.Length / 1024.0 / 1024.0, 2); // size in MB
dr["LastWriteTime"] = fi.LastWriteTime;
dr["ReadOnly"] = fi.IsReadOnly;
dr["CreationTime"] = fi.CreationTime;
dr["Ext"] = fi.Extension;
tblFiles.Rows.Add(dr);
}
tblFiles.DefaultView.Sort = "Size desc";
grdFiles.DataSource = tblFiles;
}
}
#endregion
}
|
|
|
|
|
You might want to read everything in this post[^] first, specifically point number 4.
You're code doesn't have anything in it to handle errors, specifically, Try/Catch blocks that would catch the specific errors, at specific points in your code, that your getting.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
i understand the rules but as you see my question is 2 lines
and i don't know where should i send and i sended all of it
|
|
|
|
|
I am making program using .NETCF
I want to make a feature which is able to download a file. To specify the location where the file can be saved, i use savefiledialog tool. But it's always saves the file to the my Device folder of the PDA.
Whereas i want to make it flexible so that the user can choose the location to save the file. I try to look for the property of the savefiledialog which reflect the location to save the file. but i can't. any help please ...
i wish to learn more from this forum
|
|
|
|
|
Introduction
It is often a common requirement in a web application to have the
ability to download a some sort of file to the clients computer. This article
will illustrate how to create and download a text file to the users computer.
Using the code
Although in the example I actually create the text file before I
stream it out to the client, I feel it is important to highlight that you don't
necessarily have to do this, as the file could actually exist on the file system
and you may want to stream it out to the client. If that is the case you may one
need to use the FileStream to read the already existing document.
We first open the file for reading and we actually read the file byte
for byte into stream, then once we have the file into a stream, we basically
then just use the Response object and download the file via the output
stream.
Response.AddHeader("Content-disposition", "attachment; filename=" + sGenName);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(btFile);
Response.End();
The real power in this snippet is in the lines above, by adding
header, you are telling the browser to download the file as an attachment. Then
you set The ContentType header which is added, sets your
MIME type so that the browser knows what kind of file it is
about to download. One can choose any of the following MIME types for the
browser.
".asf" = "video/x-ms-asf"
".avi" = "video/avi"
".doc" = "application/msword"
".zip" = "application/zip"
".xls" = "application/vnd.ms-excel"
".gif" = "image/gif"
".jpg"= "image/jpeg"
".wav" = "audio/wav"
".mp3" = "audio/mpeg3"
".mpg" "mpeg" = "video/mpeg"
".rtf" = "application/rtf"
".htm", "html" = "text/html"
".asp" = "text/asp"
'Handle All Other Files
= "application/octet-stream"
A full example of how to go about downloading a text file could like
the code below.
C#
Collapse
protected void Button1_Click(object sender, EventArgs e)
{
string sFileName = System.IO.Path.GetRandomFileName();
string sGenName = "Friendly.txt";
using (System.IO.StreamWriter SW = new System.IO.StreamWriter(Server.MapPath("TextFiles/" + sFileName + ".txt")))
{
SW.WriteLine(txtText.Text);
SW.Close();
}
System.IO.FileStream fs = null;
fs = System.IO.File.Open(Server.MapPath("TextFiles/" + sFileName + ".txt"), System.IO.FileMode.Open);
byte[] btFile = new byte[fs.Length];
fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=" + sGenName);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(btFile);
Response.End();
}
VB.NET
Collapse
Dim strFileName As String = System.IO.Path.GetRandomFileName()
Dim strFriendlyName As String = "Friendly.txt"
Using sw As New System.IO.StreamWriter(Server.MapPath("TextFiles/" + strFileName + ".txt"))
sw.WriteLine(txtText.Text)
sw.Close()
End Using
Dim fs As System.IO.FileStream = Nothing
fs = System.IO.File.Open(Server.MapPath("TextFiles/" + strFileName + ".txt"), System.IO.FileMode.Open)
Dim btFile(fs.Length) As Byte
fs.Read(btFile, 0, fs.Length)
fs.Close()
With Response
.AddHeader("Content-disposition", "attachment;filename=" & strFriendlyName)
.ContentType = "application/octet-stream"
.BinaryWrite(btFile)
.End()
end with
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' string sFileName = System.IO.Path.GetRandomFileName();
Dim sFileName As String
sFileName = System.IO.Path.GetTempFileName
' string sGenName = "Friendly.txt";
Dim sGenName As String = "Friendly.txt"
'YOu could omit these lines here as you may not want to save the textfile to the server
'I have just left them here to demonstrate that you could create the text file
'dim System.IO.StreamWriter SW = new System.IO.StreamWriter(Server.MapPath("TextFiles/" + sFileName + ".txt")))
Dim sw As System.IO.StreamWriter
sw = New System.IO.StreamWriter(Server.MapPath("TextFiles/" + sFileName + ".txt"))
sw.WriteLine("sdfdsfdfsdfsdafasdfasd")
'SW.WriteLine(txtText.Text);
sw.Close()
' System.IO.FileStream(fs = null)
Dim fs As System.IO.FileStream
' fs = 0
fs = System.IO.File.Open(Server.MapPath("TextFiles/" + sFileName + ".txt"), System.IO.FileMode.Open)
' byte[] btFile = new byte[fs.Length];
Dim btFile(fs.Length) As Byte
fs.Read(btFile, 0, Convert.ToInt32(fs.Length))
fs.Close()
Response.AddHeader("Content-disposition", "attachment; filename=" + sGenName)
Response.ContentType = "application/octet-stream"
Response.BinaryWrite(btFile)
Response.End()
End Sub
|
|
|
|
|
Next time, just supply the link to the article. Do NOT copy and pase the whole thing into a forum post!
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Write this code according to ur requirment in button click event. when user click the button than save dialog open and user easily save the file where he want.try to understand by this conde in vb.net
Function saveCopyLocal(ByVal FSaveURL)
'source file
Dim strSrcFileName As String = "\foldername\" + FSaveURL + ".txt"
'targat file
Dim strTargetName As String = "Rapid_reporting_Pilot.txt"
Try
Dim fs As System.IO.FileStream
fs = System.IO.File.Open(Server.MapPath(strSrcFileName), System.IO.FileMode.Open)
Dim btFile(fs.Length) As Byte
fs.Read(btFile, 0, fs.Length)
fs.Close()
With Response
.AddHeader("Content-disposition", "attachment;filename=" & strTargetName)
.ContentType = "text/txt"
.BinaryWrite(btFile)
.End()
End With
Catch ex As Exception
End Try
End Function
|
|
|
|
|
Wirte this code in button event click event and when user click the button the a save dialog will be open and user can easily save the file.
Function saveCopyLocal(ByVal FSaveURL)
'strSrcFileNmae=source file name with relative path
Dim strSrcFileName As String = "\folderName\" + FSaveURL + ".txt"
'strTargetName=name of file from which name u like to save and user can 'aslso change the name
Dim strTargetName As String = "Rapid_reporting_Pilot.txt"
' Dim sw As System.IO.StreamWriter
' sw = New System.IO.StreamWriter(Server.MapPath(strSrcFileName))
' sw.Close()
Try
' Dim fs As System.IO.FileStream = Nothing
Dim fs As System.IO.FileStream
fs = System.IO.File.Open(Server.MapPath(strSrcFileName), System.IO.FileMode.Open)
Dim btFile(fs.Length) As Byte
fs.Read(btFile, 0, fs.Length)
fs.Close()
With Response
.AddHeader("Content-disposition", "attachment;filename=" & strTargetName)
.ContentType = "text/txt"
.BinaryWrite(btFile)
.End()
End With
Catch ex As Exception
End Try
End Function
|
|
|
|
|
Dude, do you have any clue how to use a forum??
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|