Oppure

Loading
02/05/08 17:55
ruggy94
Nel mio programma di disegno ho aggiunto nel form_load() la funzione per poter aprire file associati all'applicazione:

Private Sub Form_Load()
If Command$() <> "" Then
Picture1.Picture = LoadPicture(Command$())
Else

End If
End Sub


Il problema e' che quando apro appunto un file associato mi viene generato l'errore: "Run-Tim Error 75: Path/File access error:'"C:\...eccetera... .bmp"'

Dove sbaglio??
Grazie anticipatamente :k:
aaa
02/05/08 18:35
manvb.net
Private Sub Form_Load()
if command <> "" then
'apri il file il cui percorso è memorizzato in command
end if
end sub

a me cosi funziona
Ultima modifica effettuata da manvb.net 02/05/08 20:05
aaa
02/05/08 18:44
Overflow
come apri il prog?? con esegui? controlla quello che c'è scritto nel messaggio di errore... secondo me c'è scritto per 2 volte il path della bitmap!!!"C:\...\file.bmp" "C:\...\file.bmp" esce una cosa del genere??
Prova a testare il programma in debug andando nelle propietà del progetto e in compilazione c'è command line argument(traduci in italiano) e metti li il path della bitmap poi testa il programma.
Ultima modifica effettuata da Overflow 02/05/08 18:45
aaa
02/05/08 20:06
manvb.net
Da msdn:

Visual Basic for Applications Reference
Path/File access error (Error 75)

During a file-access or disk-access operation, for example, Open, MkDir, ChDir, or RmDir, the operating system couldn't make a connection between the path and the file name. This error has the following causes and solutions:

The file specification isn't correctly formatted.
A file name can contain a fully qualified (absolute) or relative path. A fully qualified path starts with the drive name (if the path is on another drive) and lists the explicit path from the root to the file. Any path that isn't fully qualified is relative to the current drive and directory.

You attempted to save a file that would replace an existing read-only file.
Change the read-only attribute of the target file or save the file with a different file name.

You attempted to open a read-only file in sequential Output or Append mode.
Open the file in Input mode or change the read-only attribute of the file.

You attempted to change a Visual Basic project within a database or document.
You can't make design changes to the project


Ultima modifica effettuata da manvb.net 02/05/08 20:07
aaa
04/05/08 14:59
ruggy94
Intanto grazie a tutti e 2 per le risposte...
@manvb.net
anche con Command (senza la $) non funziona

@Overflow
Non mi da il doppio percorso, ma forse (non vorrei dire cavolate) il problema e' che il Command indica il percorso del file tra virgolette "", mentre quando apro il file con il pulsante Apri apre il percorso senza le virgolette.

Spiegando meglio, con il Command il percorso e':
"C:\Users\user\Desktop\prova01.bmp"

Con il pulsante Apri il percorso e':
C:\Users\user\Desktop\prova01.bmp

Se il problema fosse questo, come lo potrei risolvere?

------------Edit-----------------
Ho provato a cambiare il command line argument (scrivendo il percorso della bitmap SENZA VIRGOLETTE) e funziona, mentre se lo scrivo con le virgolette mi dà lo stesso errore di prima, quindi e' probabile che il problema sia delle virgolette, anche se non so come fare a toglierle
Ultima modifica effettuata da ruggy94 04/05/08 15:04
aaa
04/05/08 15:18
gantonio
Private Sub Form_Load() 
  If Command$() <> "" Then 
    Picture1.Picture = LoadPicture(Replace$(Command$(), Chr$(34), "")) 
  End If 
End Sub
aaa
04/05/08 16:15
ruggy94
ok funziona grazie 1000 a tutti :k:
aaa