I'm getting an error "index was out of range. must be a non-negative and less than the size of the collection"
When I comment out all of the lines besides console.wirteline(archivetoupload) the loop works correctly.
Any ideas?
namespace glacier.amazon.com.docsamples
{
class ArchiveUploadHighLevel
{
public static void Main(string[] args)
{
string vaultName = "testvault";
string archiveToUpload = "";
DirectoryInfo info = new DirectoryInfo(@"c:\test\");
FileInfo[] files = info.GetFiles().OrderByDescending(d => d.CreationTime).ToArray();
foreach (FileInfo file in files)
{
try
{
archiveToUpload = info + file.ToString();
Console.WriteLine(archiveToUpload);
var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.APSoutheast2);
// Upload an archive.
string archiveId = manager.Upload(vaultName, "Test Document", archiveToUpload).ArchiveId;
Console.WriteLine("Archive ID: (Copy and save this ID for the next step) : {0}", archiveId);
Console.ReadKey();
}
catch (AmazonGlacierException e) { Console.WriteLine(e.Message); }
catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
catch (Exception e) { Console.WriteLine(e.Message); }
Console.WriteLine("To continue, press Enter");
Console.ReadKey();
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire