Undzwar folgendes, ich möchte in meinem Programm Dateien auf ein Angeschlussenes Gerät hoch bzw. herunterladen und wollte fragen wie ich das machen soll.
Folgendes:
Im Textfeld gebe ich den Speicherort und Dateiname an, von der Datei die hochgeladen werden soll oder ich klicke auf durchsuchen (1) (button4) und wähle die Datei.
Danach klicke ich auf Upload (3) (button2) , und wähle den Speicherort der Datei aus. wenn ich dann Upload mit ok beende, sollen die Dateien kopiert werden. mit ok (2)beende ich das fenster upload wieder.
Meine Frage: was Schreibe ich in den Code damit das gerät erkannt wird und ich die Daten auf ein Mobiles Gerät (PDA) speichern kann? Das geht doch irgendwie mit der Remote API!?
Vielen Dank schonmal im voraus!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class upload : Form
{
public upload()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void button4_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ textBox1.Text = openFileDialog1.FileName; }
}
/*public void CopyFileOnDevice(
string SourceFile,
string DestinationFile
);*/
private void button2_Click(object sender, EventArgs e)
{
if (folderBrowserDialogUpload.ShowDialog() == DialogResult.OK)
pictureBox1.Show();
{
string[] arr;
arr = textBox1.Text.Split('\\');
//arr.Length;
int int1 = arr.Length;
System.IO.File.Copy(textBox1.Text, folderBrowserDialogUpload.SelectedPath + "\\" + arr[int1 - 1]);
}
}
private void upload_Load(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
Real programmers don't comment.
If it was hard to write, it should be hard to understand!
wenn das gerät beschreibbar ist, schau dir die File Klasse an...
mfg hannes
D.h.? Ich kann vom Arbeitsplatz drauf zugreifen aber nich von dem Openfiledialog oder dem folderbrowserdialog.
Real programmers don't comment.
If it was hard to write, it should be hard to understand!
wenn im explorer für das gerät ein buchstabe zugewisen ist kann auch openfiledialog darafu zugreifen und dann kannst du auch mit :
File.Copy das file raufkopieren...
mfg hannes
Das is ja mein Problem, das is kein Buchstabe, da Steht nur "Mobiles Gerät".
Real programmers don't comment.
If it was hard to write, it should be hard to understand!
Hast doch schon das Stichwort: RAPI. In der Hilfe findest du allesFunktionen. Damit kannst du spielend einen Folder-Dialog basteln (oder einfach einen vorhandenen anpassen) und auch das kopieren erledigen.
Sag mir mal wo oder geb mir nen Link! (!!BITTE!!
Real programmers don't comment.
If it was hard to write, it should be hard to understand!
Ich muss euch trotzdem nochmal den Code schicken, denn ich komm nicht klar! schaut mal bitte durch uns sagt mir wie ich mein problem lösen kann, dass man von einem folderbrowser- oder openfiledialog auf ein Mobiles Gerät zugreifen kann.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
public partial class upload : Form
{
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct RAPIINIT
{
int cbSize;
int heRapiInit;
int hrRapiInit;
}
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
public int nLength;
public int lpSecurityDescriptor;
public int bInheritHandle;
}
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeCloseHandle(int hObject);
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeCreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile);
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeRapiInitEx([System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Struct)] ref RAPIINIT pRapiInit);
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeRapiInit();
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeRapiUninit();
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeReadFile(int hFile, StringBuilder lpBuffer, int nNumberOfbytesToRead, out int lpNumberOfbytesRead, int lpOverlapped);
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeWriteFile(int hFile, StringBuilder lpBuffer, int nNumberOfbytesToWrite, out int lpNumberOfbytesWritten, int lpOverlapped);
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int GetLastError();
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
static extern int CeSetEndOfFile(int hFile);
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeGetFileSize(int hFile, int lpFileSizeHigh);
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeGetLastError();
[System.Runtime.InteropServices.DllImport("rapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
public static extern int CeCopyFile(StringBuilder lpExistingFileName, StringBuilder lpNewFileName, StringBuilder bFailIfExists);
public upload()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void button4_Click(object sender, EventArgs e)
{
CeRapiInit();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ textBox1.Text = openFileDialog1.FileName; }
}
private void button2_Click(object sender, EventArgs e)
{
CeRapiInit();
if (folderBrowserDialogUpload.ShowDialog() == DialogResult.OK)
pictureBox1.Show();
{
string[] arr;
arr = textBox1.Text.Split('\\');
//arr.Length;
int int1 = arr.Length;
System.IO.File.Copy(textBox1.Text, folderBrowserDialogUpload.SelectedPath + "\\" + arr[int1 - 1]);
}
}
private void upload_Load(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void folderBrowserDialogUpload_HelpRequest(object sender, EventArgs e)
{
}
}
}
Real programmers don't comment.
If it was hard to write, it should be hard to understand!
Bitte auch diesen Beitrag Einstiegspunk wird nicht gefunden lesen!
Baka wa shinanakya naoranai.
Mein XING Profil.