hi guys... i new person using vb.net
i have some problem in copy a file into specific directory create by user...
below is coding that write that may help u all to solve my problem -
Imports System.IO
-
-
Public Class Form1
-
Inherits System.Windows.Forms.Form
-
-
#Region " Windows Form Designer generated code "
-
#End Region
-
-
Dim filePath As String
-
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
-
End
-
End Sub
-
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
TextBox1.Text = ""
-
ComboBox1.Text = ""
-
TextBox2.Text = ""
-
TextBox1.Focus()
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim souFile As String = TextBox2.Text
-
Dim desFile = TextBox1.Text
-
Dim result As StreamWriter
-
'dirCopy = TextBox2.Text
-
Try
-
If TextBox1.Text = "" And ComboBox1.Text = "" And TextBox1.Text = "" Then
-
MsgBox("sorry", MsgBoxStyle.OKOnly, "Alert")
-
Else
-
Directory.CreateDirectory("C:\Documents and Settings\Crazy_Frog\My Documents\Visual Studio Projects\CreatePath\Document" & "\" & ComboBox1.Text & "\" & TextBox1.Text)
-
File.Copy(TextBox1.Text, TextBox2.Text)
-
MsgBox("File copy successful", MsgBoxStyle.Information, "Information")
-
End If
-
-
Catch ex As Exception
-
MsgBox("File copy successful", MsgBoxStyle.Information, "Information")
-
End Try
-
End Sub
-
-
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
-
OpenFileDialog1.ShowDialog()
-
filePath = OpenFileDialog1.FileName
-
TextBox2.Text = filePath
-
End Sub
-
End Class
-
please help me... urgent...
4 5412
What exactly is the problem?
It looks ok enough.
Although where you catch your exception you still have it display the success message, which could be confusing.
If you have an error, try debugging it to see what the situation is when it errors.
ok.... actually textbox1.text and combobox1.text represent folder that i create...
and textbox2.text is the openFileDialog1.showDialog() function... from the openFileDialog1.showDialog() function i want to save the file that selected in textbox2.text to the following input user based on textbox1.text and combobox1.text...
actually... i can create the folder based on input from user... but i cannot copy the file into the directory that user create....
i hope u get an idea for this problem....
thanks....
Right I gathered that it wasn't working.
WHAT PART is not working, surely there is an error message somewhere?
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
OpenFileDialog1.ShowDialog()
filePath = OpenFileDialog1.FileName TextBox2.Text = filePath
End Sub
* this button for open file dialog where the path are written on the TextBox2.Text Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim result As StreamWriter
Try
If TextBox1.Text = "" And ComboBox1.Text = "" And TextBox1.Text = "" Then
MsgBox("sorry", MsgBoxStyle.OKOnly, "Alert")
Else Directory.CreateDirectory("C:\Documents and Settings\Crazy_Frog\My Documents\Visual Studio Projects\CreatePath\Document" & "\" & ComboBox1.Text & "\" & TextBox1.Text)
'File.Copy(TextBox1.Text, TextBox2.Text)
MsgBox("File copy successful", MsgBoxStyle.Information, "Information")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
* this Button1_Click for creating folder where the path are specifically created based on Directory.CreateDirectory
my problem actually are to copy the file based on TextBox2.Text (path) to the Directory.CreateDirectory
if i click the Button1_Click, the folder will be created but the the file based on TextBox2.Text not exist..
and another thing... i forgotten to create an error massage....
maybe you have an idea...
:)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Goran Djuranovic |
last post by:
I am trying to COPY, not deploy, ASP.NET application. I know that asp.net
application
can be copied without any problems by using "Copy Project" menu item, but
only if it
doesn't have any Crystal...
|
by: Grey |
last post by:
I have a ASP.NET web application which is required to copy file from windows
server to Novell Netware server. I have used impersonation to connect to
Netware server. The application works fine when...
|
by: MAF |
last post by:
Does anyone know why in 2005 I might be getting this error everytime I try
and recompile?
Error 226 Unable to copy file "obj\Debug\myfile.dll" to
"bin\Debug\myfile.dll". The process cannot...
|
by: Standist |
last post by:
I want install software on PC in my local network.
First I want copy file to the PC through default share like c$ or d$ on the
PC.
Then install the software through wmi.
I have the administrator...
|
by: Pivalig |
last post by:
Hello, i try to copy file from Pocket PC to network printer using this code :
destination = "\\\\pc1\\ep1000\\Bill.txt";
File.Copy("\\Program Files\\MobileKhelner\\Bill.txt", destination);
...
|
by: CGatto |
last post by:
Hi,
We have just started getting the following error during compiles of our
forms-based application. We are developing in VS2008, VB.Net, with Team
Foundation Server-based source control.
...
|
by: rizwan6feb |
last post by:
Hello everybody. I need help on how to use copy function to copy file from one computer to another ( or any other way i can copy the file). The computers are on a local network.
|
by: Irrigho5 |
last post by:
i have the open file function just need help with the copy file function and main
Ask for a source filename and a target filename. Then copy the source file to the target file using the...
|
by: foss |
last post by:
hi all,
I am not able to copy file from a directory in the server to another directory.
Here,
the source is outside the web root directory and the destination is inside the web root directory. ...
|
by: rajibdotnet |
last post by:
Till Date, I find no solution to the problem below.
Unable to copy file "obj\Debug\Tax2010.dll" to "bin\Tax2010.dll". The process cannot access the file 'bin\Tax2010.dll' because it is being used...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |