Les Snippets

Connexion

Enregistrer un tableau de Bytes dans un fichier

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 17/03/2006 23:14:43 et initié par Nix [Liste]
Vue : 8562
Catégorie(s) : Fichier / Disque
Langages dispo pour ce code :
- VB 2005, VB.NET 1.x
- C# 1.x, C# 2.x
- Java
- Delphi 5
- VB6, VBA



Langage : VB.NET 1.x , VB 2005
Date ajout : 17/03/2006
Posté par Nix [Liste]
Public Sub TableauDeByteVersFicher(ByVal CheminFichier As String, ByVal TableauDeByte() As Byte)
 
	Dim MonFileStream As New System.IO.FileStream(CheminFichier, System.IO.FileMode.Create) 
	MonFileStream.Write(TableauDeByte, 0, TableauDeByte.Length - 1)
	MonFileStream.Close()

End Sub
' Exemple d'utilisation : 
TableauDeByteVersFicher("C:\LeChemin\DeVotre\Fichier.Ext", MonTableauDeBytes) 

Langage : C# 1.x , C# 2.x
Date ajout : 17/03/2006
Posté par Nix [Liste]
public void TableauDeByteVersFicher(string CheminFichier, byte[] TableauDeByte) 
  {
	System.IO.FileStream MonFileStream = new System.IO.FileStream(CheminFichier, System.IO.FileMode.Create); 
	MonFileStream.Write(TableauDeByte, 0, TableauDeByte.Length - 1);
	MonFileStream.Close();
  }

// Exemple d'utilisation :

TableauDeByteVersFicher(@"C:\LeChemin\DeVotre\Fichier.Ext", MonTableauDeBytes);

Langage : Java
Date ajout : 16/05/2006
Posté par Arglanir [Liste]

public static void tableauDeBytesVersFichier

  (byte[] tableau, java.io.File fichier)
  throws java.io.IOException {
    java.io.FileWriter f = new java.io.FileWriter(fichier);
    //on itère sur chaque élément, car il n'y a pas de fonction globale
    for (int i = 0; i < tableau.length; i++)
        f.write(tableau[i]);
    f.close();
}


Langage : Delphi 5
Date ajout : 05/08/2006
Posté par f0xi [Liste]
type
   pByteArray = ^TByteArray;
   TByteArray = array[0..255] of byte;
 
 procedure WriteByteFile(const FileName : string; const BA : TByteArray);
 var TFS : TFileStream;
 begin
   TFS := nil;
   try
     TFS := TFileStream.create(FileName, fmCreate);
     TFS.WriteBuffer(BA,SizeOf(TByteArray));
   finally
     TFS.Free;
   end;
 end;
 
 
utilisation : procedure TForm1.FormCreate(Sender : TObject); var TBA : TByteArray;      x : integer; begin   for X := 0 to 255 do TBA[X] := 255;   WriteByteFile('c:\test.bin',TBA); end;
Langage : VB6 , VBA
Date ajout : 23/06/2007
Posté par PCPT [Liste]
Private Sub CreateFileFromBytes(ByVal  sPath As  String, ByRef aBytes() As Byte)
    Dim FF As Integer
    FF = FreeFile
    Open sPath For Binary As #FF
        Put #FF, , aBytes
    Close #FF
End Sub


Snippets en rapport avec : Tableau, Byte, Array, File, Fichier



Codes sources en rapport avec : Tableau, Byte, Array, File, Fichier

{Visual Basic, VB6, VB.NET, VB 2005} COMPRESSION
Fonction pour comprimer un tableau de byte...

{Flash} FAIRE TOURNER UN TABLEAU (ARRAY)
Il est parfois utile ou nécessaire de faire 'tourner' un Array, c'est à dire de décaler tout le cont...

{Flash} UTILISATION DYNAMIQUE D'UN TABLEAU
Utilisation d'un tableau : " array ", pour se logger, faire une recherche dans les données existante...

{Visual Basic, VB6, VB.NET, VB 2005} FAT RECOVER : RÉCUPÉRER LES FICHIERS EFFACÉS DE VOS PARTITIONS FAT (CARTE MÉMOIRE ET CO)
Ce code permet de récupérer les fichiers effacés sur les partitions FAT12, FAT16 et FAT32. Pour cela...

{PHP} DÉTERMINATION DU CHEMIN D'INDEXAGE MENANT À UNE VALEUR DANS UN TABLEAU MULTI-DIMENSIONNEL
Cette fonction sert à trouver tous les indices qu'il faut suivre dans un tableau multidimentionnel p...

{Javascript / DHTML} TRANSFORMER UN TABLEAU JAVASCRIPT EN UN TABLEAU HTML
Cette fonction prend en argument une variable javascript qui est un tableau, une matrice à x lignes ...

{PHP} CLASSE DIRECTORYITERATOR POUR PHP4
Dans le cadre d'un de mes projets, j'utilise la classe PHP 5 DirectoryIterator vraiment utile pour l...

{Visual Basic, VB6, VB.NET, VB 2005} ENREGISTRER ET CHARGER LISTVIEW DANS FICHIER AVEC IMAGE ETC...
Salut a tous, Voici un ptit code pour enregistrer une listview dans un fichier et la recharger de...

{JAVA / J2EE} CLASS FILE UTILITIES / CLASSE UTILITAIRE DE MANIPULATION DE FICHIERS
Petite classe toute bête de manipulation de fichiers, simple mais tellement utile ;) voila, si ça p...

{Visual Basic, VB6, VB.NET, VB 2005} MODIFICATIONS NOM DE FICHIERS DANS UN MÊME RÉPERTOIRE
C'est un tout petit code tout simple mais qui est pratique si on veut modifier rapidement les noms d...